10

I have an embedded DLL in my app and I need to write it to the filesystem at runtime. I have this so far:

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

I just need to write _rawstream to a file now.

EDIT: This has to be .NET Framework 2 and CopyTo does not exist :(

Oded
  • 489,969
  • 99
  • 883
  • 1,009
Jimmy D
  • 5,282
  • 16
  • 54
  • 70

3 Answers3

9

Use a FileStream and write to it.

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

_rawstream.CopyTo(fs)

Edit:

For pre 4.0 see this.

Community
  • 1
  • 1
Oded
  • 489,969
  • 99
  • 883
  • 1,009
8
My.Computer.FileSystem.WriteAllBytes(output file, My.Resources.resourcename, False)
Jimmy D
  • 5,282
  • 16
  • 54
  • 70
1
using (FileStream fileStream = File.OpenWrite("MyFile.bin"))
{
    _rawstream.CopyTo(fileStream);
}

EDIT: Oops, sorry, that's C# but the VB should be similar

GazTheDestroyer
  • 20,722
  • 9
  • 70
  • 103