views:

24

answers:

2

I have a test project Company.Test which is located under C:\Dev\Projects\Tests folder When I run a test, I am an xml file under the Tests folder, and I would like to get the path " C:\Dev\Projects\Tests" from the test method. Is there a way to get the current project's folder path?

+2  A: 

Please note that the unit tests aren't ran in the project directory. MSTest copies them to a different location and when you don't take special care, your xml file isn't copied to that location. You must configure this explicitly in the MSTest configuration. You can do this byby going to Test / Edit Test Run Configurations / Deployment. You can use the "Add File..." button to add the xml file.

Steven
+1  A: 

Try System.Environment.CurrentDirectory.

Gerrie Schenck