Custom Search

Saturday, December 24, 2005

How To Load an Embedded Resource in C#

1) Add an Embedded Resource in your C# Project (ex: image1.bmp);
2) In your code use this call to load the Bitmap :

Bitmap image = new Bitmap(GetType().Module.Assembly.
GetManifestResourceStream("MyApplicationNamespace.image1.bmp"));

GetManifestResourceStream("ApplicationNamespace.
ResourceFileWithExtension").
or
GetManifestResourceStream("ApplicationNamespace.FolderName.
ResourceFileWithExtension").
Depending where the Resource File is located in your project.

No comments: