I made a windows service that installs into a directory c:\Program Files\My Service. Along with the executable, I have an XML file that is installed in the same directory. This XML file is used by the service to obtain user information.
In the service code, I read the file as if it were local to the executable. Example:
DataSet ds = new DataSet();
ds.ReadXml("Foo.xml");
However, when I start the service, the service throws an exception:
Could not find file 'C: \ Windows \ system32 \ Foo.xml'
Since the executable lives in c:\Program Files\My Service, I expected the Windows service to look for the XML file in c:\Program Files\My Service\Foo.xml. Obviously, this is not so.
How to make a service look for a (relatively) Foo.xml file in the same place where the service executable lives?