Embedded Resource Files

D

doomsday123

Is there an easy way to copy an Embedded Resource file to the file
system? I have a config file that is an Embedded Resource in my project
that I want to copy to a location in the file system but the only way I
can think of doing it is to read it and then create a new file and
write to the file.
 
G

Guest

Get the resource stream by using Stream s =
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("myResource");

Then simply write the Stream to the files system, using the correct extension!

Hope the helps.
--
Good luck!

Shailen Sukul
Architect
(BSc MCTS, MCSD.Net MCSD MCAD)
Ashlen Consulting Service P/L
(http://www.ashlen.net.au)
 
L

Laurent Bugnion

Hi,

Shailen said:
Get the resource stream by using Stream s =
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("myResource");

Then simply write the Stream to the files system, using the correct extension!

Or, to simplify the extension thing, simply save the file in the
resources using the extension already.

And remember that the path in the resources is separated with dots, not
slashes.

myAssembly.GetManifestResourceStream("myFolder.myResource.jpg");

HTH,
Laurent
 

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