title: How to get path of project from test project?
body: <p>I have a unit test project set up in the same solution as my project in Visual Studio. Unit testing is being done via built in Unit Testing tools in Visual Studio (included in Premium and above versions). I need to load a file that is in the path of the project itself, not the test project, while running unit tests in the test project.</p>
  
  <p>The file to include is part of the main project, and has the following properties:</p>
  
  <ul>
  <li>Build Action: Content</li>
  <li>Copy to Output Directory: Always</li>
  </ul>
  
  <p>I need to write a unit test that for a function that depends on this file, or I will hit an error state and will not be able to write tests for 100% coverage on that function.</p>
  
  <p>How would I get the execution path of the actual project from the unit test project?</p>
  
  <p>Edit: The specific function reads all lines in the config file and stores them one at a time in a list. Sample code follows:</p>
  
  <pre><code>public List&lt;string&gt; LoadConfigFile() {
      List&lt;string&gt; models = new List&lt;string&gt;();
      StreamReader sr = new StreamReader(Path.GetDirectoryName(Application.ExecutablePath) + @"\" + Properties.Resources.SupportedModelsConfigFile);
  
      while ((line = sr.ReadLine()) != null)
      {
          models.Add(line);
      }
  
      sr.Close();
      return models;
  }
  </code></pre>
  
  <p>Primary Problem: Application.ExecutablePath works fine when running the program inside or outside of the IDE, but when running unit tests, it sends me to a directory within visual studio, specifically this directory:</p>
  
  <pre><code>C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\QTAgent32.exe
  </code></pre>