title: Writing Unit Tests: How to get folder with testfiles programmatically
body: <p>I am writing unit tests in visual studio 2010.<br>
  For test some functionality, I have added a folder with testfiles.<br>
  I need to get this folder programmatically without a hard path in a string.</p>
  
  <p>The folder contains in <code>&lt;projectDirectory&gt;/TestFiles</code> </p>
  
  <p>I have tried to use <code>AppDomain.CurrentDomain.BaseDirectory</code>.
  This will only work if I run my unit tests with resharper.<br>
  result is <code>&lt;projectDirectory&gt;/bin/debug</code> so I can easily go to TestFiles.</p>
  
  <p>If I am running test with visual studio, the BaseDirectory is:<br>
  <code>&lt;sameFolderAsSolutionFile&gt;\TestResults\&lt;username&gt;_&lt;pcname&gt; &lt;datatime&gt;\Out</code></p>
  
  <p>I have moved my solution file to another folder. So my projects aren't in the same folder as my solution file.<br>
  Example:<br>
  <code>&lt;sameFolderAsSolutionFile&gt; = C:\SolutionFiles</code><br>
  <code>&lt;projectDirectory&gt; = C:\Projects\MyProject</code> </p>
  
  <p>Can someone tell me how to get the path to my test-files without using a hardcoded string?</p>
  
  <p><strong>EDIT</strong><br>
  I haven't found a solution yet.<br>
  Visual Studio is using another build folder for testing.
  So everything what is normally builded into the bin folder will be builded into another folder for the test.</p>
  
  <p><strong>MY TEMP-SOLUTION</strong><br>
  I have added a App.config file in my test project.
  In this configuration file I have added a setting with the required path to the test files:  </p>
  
  <pre><code>&lt;appSettings&gt;
    &lt;add key="TestFiles" value="C:\Projects\MyProject\TestFiles"/&gt;
  &lt;/appSettings&gt;
  </code></pre>