Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Visual Studio using resource files

I'm trying to add two image files into the solution, so they will be compiled into the .exe, so I can load them right there instead of from an absolute path on the computer.

I believe I need to use resource files in Visual Studio, but I never have before. If I'm completely on the wrong track, please correct me.

Here's what I've done so far. In Visual Studio 2010 Solution Explorer, right click PropertiesOpenResourcesAdd ResourceAdd Existing File...

So now I have both my images in the PropertiesResources tab. Now how do I get them back out in the C# code?

I'm using C#, Windows Forms and Visual Studio 2010.

PictureBox pic;
pic.Image = new Bitmap( /* What is the address now? */ );
like image 765
jb. Avatar asked Dec 02 '10 04:12

jb.


1 Answers

You can get them like Properties.Resources.<name_of_your_resource>

like image 144
Hps Avatar answered Sep 21 '22 05:09

Hps