App.config修改在退出后还原

时间:2018-11-14 18:58:49

标签: c# visual-studio-2015 config app-config configurationmanager

我正在修改MyApp.vhost.exe,并且正如我在文本编辑器中看到的那样修改了App.vhost.exe,但是当我停止调试应用程序时,App.config值恢复为原来的值。更改之前。我在做错什么或我想念什么?

Configuration exeConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var section = exeConfiguration.GetSection(monitorSectionElementName);

if (section != null)
{
    var monitorPathElements = (section as MonitorSection).MonitorPaths;
    monitorPathElements[monitorPath].CheckSum = checkSum;
}

exeConfiguration.Save(ConfigurationSaveMode.Full, true);
ConfigurationManager.RefreshSection(monitorSectionElementName);

0 个答案:

没有答案