How to get to embedded resources from assemblies?

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.
 
P

Pete Davis

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top