We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

C#  GetManifestResourceStream - how to reference an embedded resource

JElster
JElster asked
on
Medium Priority
2,036 Views
Last Modified: 2012-05-11
Hi..
I have an image file in a project under an images folder.  
...images/myImage.png

How do I reference it in GetManifestResource stream?
It's an embedded resource.

GetManifestResourceStream('MyAssembly.resources.myImage.png') does not work... what should it be..

Comment
Watch Question

Carlos VillegasFull Stack .NET Developer

Commented:
You can do this:
System.Drawing.Image myImage = System.Drawing.Image.FromStream(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MyAssembly.resources.myImage.png"))

Open in new window


Use:
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames()

Open in new window

To read yours resources names.

Author

Commented:
None of the resource names have the image file in it.
When I  'add the name'  I get invalid parameter
Full Stack .NET Developer
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
CERTIFIED EXPERT
Top Expert 2009

Commented:
Just FYI, for WinForms you can also do something like:

        private void button1_Click(object sender, EventArgs e)
        {
            Bitmap bmp = new Bitmap(this.GetType(), "myImage.png");
            pictureBox1.Image = bmp;
        }
Carlos VillegasFull Stack .NET Developer

Commented:
Hello Idle_Mind, mmm I see, I tested it, just I have to remove the root namespace from the resource name to make it work. thank you.

Author

Commented:
thanks!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.