i don't think using a filestream is the problem here.
is the OOM exception thrown at this line?:
byte[] clientwz = Properties.Resources.NudieStory;
if yes then the problem is getting the resource not how to save it.
maybe try to open it like shown here:
http://support.microsoft.com/kb/319292
Code:
_assembly = Assembly.GetExecutingAssembly();
_imageStream = _assembly.GetManifestResourceStream("MyNamespace.MyImage.bmp");
after that create a binaryreader, filestream and a binarywritter and loop over the resource stream and read/write the data.
something like this:
Code:
_assembly = Assembly.GetExecutingAssembly();
resStream = new BinaryReader(_assembly.GetManifestResourceStream("MyNamespace.MyImage.bmp"));
string fileName = myfolder.Text + "\\awesome.exe";
byte[] buffer = new byte[1024];
using(BinaryWriter binWriter = new BinaryWriter(File.Open(fileName, FileMode.Create)))
{
while (resStream.BaseStream.Position < resStream.BaseStream.Length)
{
int cnt = resStream.Read(buffer, 0, 1024); // cnt may be less than 1024 when the stream is at the end
binWriter.Write(buffer, 0, cnt);
}
}
resStream.Close();