The static method Assembly.GetEntryAssembly()
will give you a reference to the entry assembly (the .exe file), and the Location
property will give you the location of the file:
Assembly.GetEntryAssembly().Location
Another way around, if you know of a type in the entry assembly, is to use the Type.Assembly
to get a reference to the assembly:
typeof(Program).Assembly.Location
If you need just the directory path, use the static Path.GetDirectoryName()
method.
Off topic: have you considered the configuration API built into .NET? I am not saying this will be better in your specific case, but I guess it is worth considering before rolling your own configuration framework.