How To Get A Stream Object From A Resource File (Console App/Windows Service Project)

If you set the files in the Resources folder to Embedded Resource then you should have seen it listed in the GetManifestResourceNames() call. You could try

var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MicroSecurity.EmailService.Resources.logo.jpg");

The name should be "MicroSecurity.EmailService.Resources.logo.jpg" if it is in the Resources folder. However, marking the file itself as an Embedded Resource defeats the purpose of the Resources file (the image itself would be embedded twice).

You can remove the resources file entirely and set each file as an Embedded Resource. At that point, there should be separate manifest resources for each file. In a C# project, each file name will be prefixed by the project namespace + the sub folder. Eg. if you add a "logo.jpg" file in a Resources/Embedded folder, the resource name will be "MicroSecurity.EmailService.Resources.Embedded.logo.jpg".

Alternatively, get the bitmap from the Resources file and convert it to a stream. You can find an example of converting a Bitmap to a MemoryStream in How do I convert a Bitmap to byte[]?


Can you use:

System.Drawing.Bitmap myLogo = MicroSecurity.Properties.Resources.logo;