title: Getting file path in ASP.NET and XDocument.Load
body: <p>I have a static class in a folder off root in my solution. In that static class' folder, there's a subfolder containing XML files. So I've got these files:</p>
  
  <pre><code>/PartialViews/Header/MyStaticClass.cs
  /PartialViews/Header/Config/en-US.xml
  /PartialViews/Header/Config/jp-JP.xml
  ...
  </code></pre>
  
  <p>I'm having trouble using <code>XDocument.Load()</code> with those XML files. Specifically, I'm trying to load the XML files from the static constructor of <code>MyStaticClass</code>.</p>
  
  <p><code>XDocument.Load()</code> can't seem to find the files, however. I've tried all these and none work:</p>
  
  <pre><code>static MyStaticClass()
  {
      XDocument doc;
  
      // These all throw exceptions relating to directory not found
      doc = XDocument.Load("/Config/en-US.xml");
      doc = XDocument.Load(@"\Config\en-US.xml");
      doc = XDocument.Load("/PartialViews/Header/Config/en-US.xml");
      doc = XDocument.Load(@"\PartialViews\Header\Config\en-US.xml");
  }
  </code></pre>
  
  <p>I also tried using <code>Assembly.GetExecutingAssembly().Location</code> and <code>Assembly.GetEntryAssembly().Location</code> before the relative path, but the assembly resolved by <code>Assembly</code> is always a .NET library (because the type is being initialized?).</p>
  
  <p>How can I load the file without changing its location in the solution?</p>