Search code examples
c#.netresourcesresx

How to save a resource from .resx to hard drive?


I have a Windows Forms project with the standard main.resx file where a .ecfg file is saved (configuration file).

How can I extract this file to the hard drive?


Solution

  • Check the namespace on your resource file. Usually they are put into the Properties namesapce. You can then access the file like this:

    byte[] b = Properties.Main.Something;    //Something being the name of the resource
    System.IO.File.WriteAllBytes(@"C:\temp\yourfile.ecfg", b);