Including Resources in .exe

As a I reply on my Non-Rectangular Form article, someone asked if you couldn't include the bitmap in the file.

Well, you can. And that is what this little article will talk about. This very little article.

When do you want to include things? If they are small and are vital for your app to run. This bitmap is vital! You could also include icons for example...

How do you do it?

Include your bitmap in your project. Go to it's properties and for 'Build Action' choose: Embedded Resource. This will compile your file into your .exe as a resource.

This was what we had to load our bitmap:

FileStream imageStream = File.OpenRead("Glass.bmp");

Bitmap imageBackground = (Bitmap)Bitmap.FromStream(imageStream);


This is now:

Bitmap imageBackground = new Bitmap(this.GetType(), "Glass.bmp");


That's it. Wasn't that simple? Your Bitmap is inside the .exe and it's loading fine.

I've uploaded this version as well.

Note: You can drag the .exe around and press 'q' to close it (for the people who haven't read the Non-Rectangular Form article ;) imagine having to kill it)

1 Comment

Comments have been disabled for this content.