Sunday, 15 September 2013

c# - What is the .NET equivalent of java's System.getProperty("user.dir")? -


I am trying to get the full path of a file in my unit test which is in the folder in my project

  Directory.GetCurrentDirectory () has tried to use;  

But it returns to the directory that is running my tests. I want to put the directory of the project (or solution) over there without hard-code. Then I can add the last part of the file name.

   

in

= "Post -text "itemprop =" text ">
  path. Gate directory name (assembly Gate accidental status (location). Location)  

you unit running

to access a file in a project subfolder, Working Easy To mark relevant files as Build = Content and copy output directory = if new, copy . If you do so, whenever you build this project, they will be copied to the corresponding folder below the assembly folder.

  • You have & lt; Project Root & gt; \ TextData is a text file, for example:
    • \ Data1.txt .
    • When you create a project in debug mode, it will be & lt; Project Root & gt; \ Bin \ Debug \ TestData \ Data1.txt .
    • The physical path in your code will be path.combin (path.gate directoryname (assembly assembly. Assembly (location.), "Test data \ data1.txt") .

No comments:

Post a Comment