Ken Vleminckx

I love deadlines. I like the whooshing sound they make as they fly by.

GetManifestResourceStream: Use an included file in your project.

You can easily use embedded files in your project.

As you see, I included an image called card.gif into my project.
I can now use this image at runtime in my application.

Dim thisExe As System.Reflection.Assembly

thisExe = System.Reflection.Assembly.GetExecutingAssembly()

Dim file As System.IO.Stream = thisExe.GetManifestResourceStream(thisExe.GetName.Name & ".Card.gif")

PictureBox1.Image = Image.FromStream(file)

Next week I will post an entire cardslibrary component. It will include all 52 cards. (From Ace to King)

- Ken

Comments

admin said:

Hey Ken,

I also used embedded resources in C# as follow:

System.Reflection.Assembly assem = System.Reflection.Assembly.GetExecutingAssembly();
pictureBox1.Image = new System.Drawing.Bitmap(assem.GetManifestResourceStream(this.GetType(), "pgbIcon.bmp"));

I had a problem when the "Default namespace" on the project properties (Common Properties --> General) was not set correctly to the namespace where I use this piece of code.

- Wesley
# December 7, 2004 9:40 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: