Hi!
My problem is that i tried to use resource files in a project using the ranorex IDE and not Visual Studio.
I created the resource file, added a string value and tried to access it using resource reader like this :
//Getting Data from the Resource file.
string appToRun;
System.Resources.ResourceReader rr = new ResourceReader("MyData");
IDictionaryEnumerator id = rr.GetEnumerator();
while(id.MoveNext()) {
if (id.Key.Equals("AppToRun")) {
appToRun = id.Value.ToString();
}
}
rr.Close();
First it did not find MyData because it looked for the file, not in project. So okey i entere ../../MyData.resx.
It said the file is not a valid resource file, although i created it with the IDE.
Is there another solution to access and use resource files in ranorex not using Visual Studio?
Thank you,
Gergely.
Adding and accessing resource files
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Hi Gergely,
Add your existing .resx file to your project by right clicking onto your project and select "Add" -> "Existing item..." on the context menu.
Please try the following code to read string values from your resource file:
Hope this helps.
Regards,
Gabor
Ranorex Support Team
Add your existing .resx file to your project by right clicking onto your project and select "Add" -> "Existing item..." on the context menu.
Please try the following code to read string values from your resource file:
Code: Select all
using System.Resources;
using System.Reflection;
ResourceManager resources = new ResourceManager("Namespace.MyData", Assembly.GetExecutingAssembly());
string appToRun = resources.GetString("AppToRun");
Regards,
Gabor
Ranorex Support Team