Click to See Complete Forum and Search --> : Embedded Resources


bkee
June 6th, 2002, 09:00 PM
In visualstudio, I add background.bmp to my project. I set the Build Action on the Properties page to "Embedded Resource". Now how do I use that embedded resource in the program?

Zeg
June 6th, 2002, 09:23 PM
Bitmap bmap= new Bitmap(typeof(Form1),"animage.gif");

bkee
June 7th, 2002, 12:09 PM
I don't understand that at all, but it works...

How about another example.
I have a file that I load up with several serialized objects. I open it like this:

Stream r = File.Open("resources", FileMode.Open, FileAccess.Read);

How would I open it if I embedded it?

Arild Fines
June 8th, 2002, 09:36 AM
Something like this:

Stream stream = this.GetType().Assembly.GetManifestResourceStream( "Namespace.resources" );