Here is a sample on how to save an embedded resource file
// Create a stream to save the file FileStream fs = new FileStream(fileName,FileMode.Create, FileAccess.Write); // Get the stream for the resource // resourceName is the full name of the resource including the namespace Stream dataStream = typeof(ClassName).Assembly.GetManifestResourceStream(resourceName); // check that we found the stream if ( dataStream != null ) { // create a buffer byte[] buffer = new byte[1024]; int readCnt = 0; //write the resource to the file while ( (readCnt = dataStream.Read(buffer,0,buffer.Length)) > 0 ) { fs.Write(buffer,0,readCnt); } // close the streams dataStream.Close(); fs.Close(); }
Extract embeded resource
IgorKov
I am moving the thread to the Win Forms forum so you dont have to repost this.
Suite
please post this in the Winforms forum
http://forums.microsoft.com/MSDN/ShowForum.aspx ForumID=8&SiteID=1
Thanks
Kbathgate
Here is a sample on how to save an embedded resource file
// Create a stream to save the file
FileStream fs = new FileStream(fileName,FileMode.Create, FileAccess.Write);
// Get the stream for the resource
// resourceName is the full name of the resource including the namespace
Stream dataStream = typeof(ClassName).Assembly.GetManifestResourceStream(resourceName);
// check that we found the stream
if ( dataStream != null ) {
// create a buffer
byte[] buffer = new byte[1024];
int readCnt = 0;
//write the resource to the file
while ( (readCnt = dataStream.Read(buffer,0,buffer.Length)) > 0 ) {
fs.Write(buffer,0,readCnt);
}
// close the streams
dataStream.Close();
fs.Close();
}