title: Loading an XML file path in C#
body: <p>I'm trying to load an XML-file, located in a folder in my project (using Visual Studio 2012).</p>
  
  <p>The structure is this:</p>
  
  <pre><code>solutionRoot\
  -  service\
  --   ServiceClass.cs
  --   AppValues.xml  &lt;-- this is the file I want to load
  </code></pre>
  
  <p>In my ServiceClass, I'm trying to read from the XML-file with the following code:</p>
  
  <pre><code>public String GetXmlElement(String elementName)
  {
      [....]
      XDocument document = XDocument.Load(@"\service\AppValues.xml");
      [...]
  }
  </code></pre>
  
  <p>Which gives the following error, when I'm trying to test the code: </p>
  
  <pre><code>Test method PandaTests.ServiceTest.ReadXmlCanReadXml threw exception: 
  System.IO.DirectoryNotFoundException: Could not find a part of the path 
  'C:\Users\MyName\Documents\GitHub\project\Project22\PandaTests\bin\Debug\service\AppValues.xml'.
  </code></pre>
  
  <p>It's obviously a problem with my path, but I can't figure out how to get the relative path right. I've looked at other questions here on stack overflow, but many of them seem overly involved. Is there an easy way to load the XML-file without giving an absolute path?</p>