How to get to embedded resources from assemblies?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an XML file that I want to embed in my exe. It is a default config
file, that my program should read from and recreate it on the user's hard
disk the first time the application is run or if they corrupt their config
file.

So I created a default.config file (XML file) and set its Build Action
property to "Embedded Resource".

What is the code to read the embedded default.config and recreate it on the
user's hard disk?

Thanks.
 
You can get the stream as follows:

Stream inFile =
Assembly.GetExecutingAssembly().GetManifestResourceStream("YourNameSpace.You
rXmlFileName.xml");

From here, you simply need to create an output stream and copy the data.

Pete
 
Back
Top