开发者

C# Visual Studio using resource files

开发者 https://www.devze.com 2023-01-27 18:11 出处:网络
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'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? */ );


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号