Adding and accessing resource files : Automation API

Adding and accessing resource files

Class library usage, coding and language questions.

Adding and accessing resource files

Postby Skarlso » Mon Aug 11, 2008 11:33 am

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.
Skarlso
 
Posts: 27
Joined: Thu Aug 07, 2008 10:11 am

Postby Support Team » Mon Aug 11, 2008 5:51 pm

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:
Code: Select all
using System.Resources;
using System.Reflection;

ResourceManager resources = new ResourceManager("Namespace.MyData", Assembly.GetExecutingAssembly());
string appToRun = resources.GetString("AppToRun");


Hope this helps.

Regards,
Gabor
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4837
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Postby Skarlso » Tue Aug 12, 2008 9:07 am

Thank you very much!!

That helped!
Skarlso
 
Posts: 27
Joined: Thu Aug 07, 2008 10:11 am


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests