Adding and accessing resource files

Class library usage, coding and language questions.
Posts: 27
Joined: Thu Aug 07, 2008 9:11 am

Adding and accessing resource files

Post by Skarlso » Mon Aug 11, 2008 10:33 am


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();

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,

User avatar
Support Team
Site Admin
Site Admin
Posts: 12087
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Mon Aug 11, 2008 4: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.

Ranorex Support Team

Posts: 27
Joined: Thu Aug 07, 2008 9:11 am

Post by Skarlso » Tue Aug 12, 2008 8:07 am

Thank you very much!!

That helped!