0

How can i just want to use my variable string like name of resource file.

For example Using Resources look like :

 bool success = FindBitmap(Properties.Resources.waypoint1, bmpScreenshot, out location);

As you see there i use resource named : waypoint1. I need to do something like that :

 string wpt1 = "waypoint1";

But i can't just do it simple like that :

bool success = FindBitmap(Properties.Resources.wpt1, bmpScreenshot, out location);

Could someone give an simple example how to do that? I searched forum but can't find solution. Please be patinent for newbie. Thank you!

EDIT 1

My Findbitmap look like :

private bool FindBitmap(Bitmap bmpNeedle, Bitmap bmpHaystack, out Point location)
Michael
  • 202
  • 1
  • 3
  • 13
  • `Properties.Resources.ResourceManager.GetObject(wpt1)` should solve your issue. If it has to return string only then `Properties.Resources.ResourceManager.GetString(wpt1)` should help you. – Chetan Mar 29 '17 at 14:19
  • Possible duplicate of [Load image from resources](http://stackoverflow.com/questions/13592150/load-image-from-resources) – ASh Mar 29 '17 at 14:22
  • Chetan Ranparyia I can't do that like you said because its a bitmap. Look my edited post. – Michael Mar 29 '17 at 14:40
  • @Ash in your example is Image i have Bitmap here try do it like in example , but i can't do that. – Michael Mar 29 '17 at 14:56
  • 1
    @Michael, `Bitmap bmp = (Bitmap)Resources.ResourceManager.GetObject(wpt1);` That is basically what `Resources` class does (`Resources.Designer.cs` file in project folder) – ASh Mar 29 '17 at 16:54

0 Answers0