This is a migrated thread and some comments may be shown as answers.

Get Project Path in static class/function

3 Answers 86 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chandresh
Top achievements
Rank 1
Chandresh asked on 16 Nov 2016, 02:00 PM

Hi,

I need the Project Path to create log files in respective folder. I am able to get the Project Path in non-static class/functions using "this.ExecutionContext.DeploymentDirectory;". However; when I try same in static classes/functions it gives error like "Keyword 'this' is not valid in a static property, static method, or static field initializer" which is valid as we cannot do that.

Is there any other way I can use get DeploymentDirectory in static class/function?

Thanks,

Chandresh Parmar

3 Answers, 1 is accepted

Sort by
0
Nikolay Petrov
Telerik team
answered on 21 Nov 2016, 09:00 AM
Hello Chandresh,

You could try to assign the path variable to a static one in the test code behind. This static variable you may access then from a static method.

Regards,
Nikolay Petrov
Telerik by Progress
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Chandresh
Top achievements
Rank 1
answered on 21 Nov 2016, 12:40 PM

Hi Nikolay,

Yes I can do that, but then I have to do that for every test in Project. I have to assign the path variable to a static one in every tests code behind file. What I want to do is to have a single variable which can be used in all tests of Projects.

Is it possible?

Thanks,

Chandresh Parmar

0
Nikolay Petrov
Telerik team
answered on 23 Nov 2016, 01:53 PM
Hi Chandresh,

In this case you may use standalone code file to store the static variable. Once you set it public you will be able to use it from your entire project.

I hope these directions are helpful.

Regards,
Nikolay Petrov
Telerik by Progress
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Chandresh
Top achievements
Rank 1
Answers by
Nikolay Petrov
Telerik team
Chandresh
Top achievements
Rank 1
Share this question
or