Validation With Regular Expression : General Questions

Validation With Regular Expression

Ask general questions here.

Validation With Regular Expression

Postby costamesakid » Tue Feb 09, 2010 12:17 am

I have a script that validates the correct default directory is displayed when the user saves an image using the application. The default directory should be:

C:\Documents and Settings\James\My Documents\System Manager

However, the username, in this case 'James' will change depending on what system the script is executed on. I tried to work around this problem by using a regular expression, but I cannot get my code to compile. Ranorex is showing the following error:

An object reference is required for the non-static field, method, or property 'ADSIasUserDefaultFileDir.SMImages.path' (CS0120)

Below is my code. Any help on this topic is greatly appreciated.

public partial class SMImages
{
public static string str = @"C:\Documents and Settings\*.*\My Documents\System
Manager";
Regex path = new Regex(str);

static SMImages()
{
//Your recording specific initialization code goes here.
}

public static void Validate_TextC__Documents_and_Setting1()
{
//Your code here. Code inside this method will not be changed by the code
generator.
Validate.Attribute (repo.FormSave_Image.TextC__Documents_and_SettingInfo, "AccessibleValue", path);
}

}
costamesakid
 
Posts: 44
Joined: Tue Jun 16, 2009 11:27 pm

Re: Validation With Regular Expression

Postby Support Team » Tue Feb 09, 2010 10:35 am

Hi costamesakid,
you have to define Regex as static too if you want to use it in a static method

see msdn for more information about static: http://msdn.microsoft.com/en-us/library ... 71%29.aspx

Best regards,
Christian
Ranorex Team
User avatar
Support Team
Site Admin
 
Posts: 2006
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to General Questions

Who is online

Users browsing this forum: No registered users and 0 guests