Get filename of current configuration file

comecme picture comecme · May 4, 2011 · Viewed 30k times · Source

I'd think this would be simple, but I can't find an answer.

I'm using remoting and I want to store the RemotingConfiguration in the app.config. When I call RemotingConfiguration.Configure I have to supply the filename where the remoting information resides. So... I need to know the name of the current configuration file.

Currently I'm using this:

System.Reflection.Assembly.GetExecutingAssembly().Location + ".config"

But this only works for windows applications, not for web applications.

Isn't there any class that can supply me with the name of the current config file?

Answer

Paul Alexander picture Paul Alexander · May 4, 2011

Try AppDomain.CurrentDomain.SetupInformation.ConfigurationFile

https://docs.microsoft.com/en-us/dotnet/api/system.appdomainsetup.configurationfile