title: How to read a text file from a Windows Service?
body: <p>I have made a Windows Service that gets installed in a <code>c:\Program Files\My Service</code> directory. Along with the executable, I have an XML file that gets installed in the same directory. This XML file is used by the service to get user defined information.</p>
  
  <p>In the code of the service I read the file as if it were local to the executable.. example:</p>
  
  <pre><code>DataSet ds = new DataSet();
  ds.ReadXml("Foo.xml");
  </code></pre>
  
  <p>However, when I run the service, the service throws an exception saying:</p>
  
  <blockquote>
    <p>Could not find file 'C:\Windows\system32\Foo.xml'</p>
  </blockquote>
  
  <p>Since the executable lives in <code>c:\Program Files\My Service</code> I expected the Windows Service to look for the XML file in <code>c:\Program Files\My Service\Foo.xml</code>. Obviously, that's not the case.</p>
  
  <p>How can I force the service to look (relatively) for the Foo.xml file in the same location where the service executable lives? </p>