2011-10-28 56 views
7

我在我的应用程序中有一个嵌入式DLL,我需要在运行时将它写入文件系统。我到目前为止:如何将流写入文件?

Dim _assembly As Assembly = Assembly.GetExecutingAssembly() 
Dim _rawstream As Stream = _assembly.GetManifestResourceStream("MyFile.dll") 

我只需要将_rawstream写入文件。

编辑:这必须是.NET Framework 2和CopyTo从不存在:(

回答

5
My.Computer.FileSystem.WriteAllBytes(output file, My.Resources.resourcename, False) 
1
using (FileStream fileStream = File.OpenWrite("MyFile.bin")) 
{ 
    _rawstream.CopyTo(fileStream); 
} 

编辑:哎呀,对不起,这是C#,但VB应该是相似的

5

使用FileStream和写它

Dim fs As new FileStream("path to new file.dll", FileMode.Create) 

_rawstream.CopyTo(fs) 

编辑:

对于预4.0看this

+0

这必须是.NET Framework 2和CopyTo不存在:( –

+0

@SixHouse - 添加到pre 4.0选项的链接。 – Oded