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);
}
}
Validation With Regular Expression
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Validation With Regular Expression
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
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