在运行时更改默认app.config
ConfigurationManager.AppSettings
Console.WriteLine(ConfigurationManager.AppSettings["SettingA"]);Console.WriteLine(Settings.Default.Setting);var combinedConfig = string.Format(CONFIG2, CONFIG);var tempFileName = Path.GetTempFileName();using (var writer = new StreamWriter(tempFileName)){ writer.Write(combinedConfig);}using(AppConfig.Change(tempFileName)){ Console.WriteLine(ConfigurationManager.AppSettings["SettingA"]); Console.WriteLine(Settings.Default.Setting);}
combinedConfig
有只小跳蛙