Get filename of current configuration file

前端 未结 2 1749
别跟我提以往
别跟我提以往 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: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("~");
    

提交回复
热议问题