【发布时间】:2020-05-27 23:40:46
【问题描述】:
我正在使用 C# .net
我需要加载一个外部配置文件 (web.config) 并覆盖当前配置中所有部分和所有元素(每个部分)的值。
即覆盖后的状态应该是:
ConfigurationManager.AppSettings = ...从 web.config 读取的应用设置...
所有部分都以此类推。
在类似代码(或更简单的代码,如果有的话)中。
string s = "c:\test\web.config";
Configuration config = ConfigurationManager.OpenExeConfiguration(s);
foreach(ConfigurationSection section in config.sections) {
// **** What to do here in order to do: ConfigurationManager.Override(section)
// so, I can use, i.e, line code such as : string s = ConfigurationManager.AppSettings["key"] ?
}
谢谢。
【问题讨论】:
标签: c# xml configuration