[C# Windows Service] Getting the absolute path of a config file
and application server and based on some user defined values which is
lifted from a user defined XML config file, the performance of the
servers are benchmarked against these user defined values.
Now the problem is that i was having the config file in a fixed
location (C:\UserConfig.config) and I hard code the location into the
XMLTextReader
XmlTextReader reader = new XmlTextReader(constObj.XML_FILE_PATH);
As per the requirements, the config file should be along with the
solution file and as the position of the solution file can change, i am
now not able to hard code those values.
I tried the Path class from the System.IO namespace
string configFilePath = Path.GetFullPath("CounterService\\CounterServiceData.config");
but even now it shows "C:\\SYSROOT\\system32\\" this as the current directory for the service. Is there any other way to get the absolute path of the config file?
Even the"Directory.GetDirectories" seems to search from the current directory which is "C:\\SYSROOT\\system32\\" eventhough the service is located elsewhere.
Kindly help me out if i was clear in explaining the scenario.

