Search code examples
c#embedded-resource

Getting image from resource file. Create general function to retrieve resources


I have a DLL, that stores the images for our project.(C# 4.0, VS2010). In the DLL there is a resource file, I'm using -

public Image Get1()
{
   return DM.DMReourceLib._1; 
}

in order to access the image _1. This way I'll end up writing 1200 get's functions, one for each image. I'm looking for a way to do

public Image GetImage(string name)
{
   return DM.DMresourceLib.name;
}

10x


Solution

  • Take a look how designer class was generated. Maybe it can help you:

    internal static System.Drawing.Bitmap price {
            get {
                object obj = ResourceManager.GetObject("price", resourceCulture);
                return ((System.Drawing.Bitmap)(obj));
            }
        }