Access the path to the app.config programmatically
Posted
by grenade
on Stack Overflow
See other posts from Stack Overflow
or by grenade
Published on 2010-04-26T13:31:26Z
Indexed on
2010/04/26
13:33 UTC
Read the original article
Hit count: 292
c#
|app-config
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.
© Stack Overflow or respective owner