Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having a subfolder into Resources folder Visual Studio C# Windows Form

Tags:

c#

winforms

I have created a folder in the resources folder (Properties.Resources). How can I use an image from there?

like image 731
Tarida George Avatar asked Oct 15 '25 16:10

Tarida George


1 Answers

Usually when adding a resource, a typesafe wrapper is generated for that resource.

So say if I added an image named "picture", I could access by:

Form.picturebox1.Image = Properties.Resources.picture;

Hope this helps

edit:

After reading your post again, I think what you are saying is you added a subfolder in your solution folder under your Resources folder.

Where I wouldn't suggest doing this because it's much simpler to add a resource such as an image through the resource designer, if you are hellbent on creating a sub folder you would then have to add a line under the root tag of your .resx file that looks something like this...

<data name="picture" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\*SubDirectory*\picture.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>

Where SubDirectory is replaced by the name of the sub folder you created. You should then be able to compile and then use Properties.Resources.picture as I showed above.

like image 97
GCD Avatar answered Oct 17 '25 05:10

GCD



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!