Access the path to the app.config programmatically
- by grenade
I am looking for a way to programmatically obtain the path to the app.config file from within a Windows Service executable.
The build process changes App.config to program-name.exe.config and I could do something like:
var configFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "program-name.exe.config");
However, I'm looking for some way of obtaining the config file name at runtime that doesn't involve hard coding the exe name into the application. ConfigurationManager has some way of doing it, so it must be possible.