Copying embedded resource as file to disk in C#

You could call

System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames();

And inspect which embedded resources are accessible. Then you can compare that against what you are passing in to see if you are indeed accomplishing what you expected to.

Also, you should consider the using keyword to dispose of your streams:

using(FileStream ResourceFile = new FileStream(FileToExtractTo, FileMode.Create))
{
    //do stuff
}

Good luck.


This is the easiest way to save an embedded resource:

  var stream = assembly.GetManifestResourceStream("name of the manifest resourse");
  var fileStream = File.Create(@"C:\Test.xml");
  stream.Seek(0, SeekOrigin.Begin);
  stream.CopyTo(fileStream);
  fileStream.Close();