How to retrieve Image from Resources folder of the project in C#

后端 未结 5 1307
一生所求
一生所求 2021-01-04 08:39

i Have some images in resources folder in my project but i want to change the picture box from these resource files of the project

5条回答
  •  Happy的楠姐
    2021-01-04 09:31

    Below is the Code to Fetch Image From Resources Folder. Normally we keep images in Resources Folder. but Sometime we have image name only with us. in that case you can Access images from Resources Folder using Image Name only.

    Below Code will Demonstrate about it.

    private System.Resources.ResourceManager RM = new System.Resources.ResourceManager("YourAppliacationNameSpace.Properties.Resources", typeof(Resources).Assembly);
    
    PbResultImage.Image = (Image)RM.GetObject(YourPictureName);
    
    • YourAppliacationNameSpace means name of your Application.
    • YourPictureName means the Picture you Want to access from Resources Folder. but Picture name must be without Extension e.g. (PNG, GIF, JPEG etc)

    hope i will be beneficial to some one.

    Thank you.

提交回复
热议问题