Get filename of current configuration file

前端 未结 2 1747
别跟我提以往
别跟我提以往 2021-02-06 22:35

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 Remo

相关标签:
2条回答
  • 2021-02-06 23:00

    Try AppDomain.CurrentDomain.SetupInformation.ConfigurationFile

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

    0 讨论(0)
  • 2021-02-06 23:16
    using System.Configuration;
    Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
    Console.WriteLine(config.FilePath);
    

    In the odd case that you have separate configuration files for specific local or roaming users, you can locate those as well using the correct ConfigurationUserLevel. For web applications, use

    WebConfigurationManager.OpenWebConfiguration("~");
    
    0 讨论(0)
提交回复
热议问题