会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
人生就是一场圣战-GODWAR
最大的敌人就是自己 No incapable except unthinkable. God helps those who help themselves
博客园
首页
新随笔
联系
订阅
管理
如何將程序的Access数据库嵌入到资源中发布
Code
1
private
string
AccessPath
=
Application.StartupPath.ToString()
+
"
\\
"
+
"
SAP_Words.dll
"
;
2
private
string
ResourcesPath
=
Application.StartupPath.ToString()
+
"
\\
"
+
"
Resources.dll
"
;
3
4
調用
WriteEmbeddedFile("SAP_Words.dll", AccessPath);
5
private
Stream GetStream(
string
name)
6
{
7
return
GetResourceAssembly().GetManifestResourceStream(
"
資源類的命名空間.
"
+
name);
8
}
9
10
private
Assembly GetResourceAssembly()
11
{
12
return
Assembly.LoadFrom(ResourcesPath);
13
}
14
15
private
void
WriteEmbeddedFile(
string
name,
string
fileName)
16
{
17
using
(Stream stream
=
GetStream(name))
18
{
19
FileInfo file
=
new
FileInfo(fileName);
20
using
(FileStream fileStream
=
file.Create())
21
{
22
byte
[] buf
=
new
byte
[
1024
];
23
int
size;
24
while
((size
=
stream.Read(buf,
0
,
1024
))
>
0
)
25
{
26
fileStream.Write(buf,
0
, size);
27
}
28
}
29
}
30
}
31
posted on
2008-08-26 17:06
巍巍边疆
阅读(
410
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部