直接上代码,这个是没有封装的
Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
cfa.AppSettings.Settings["IsExportLock"].Value = autoexportdata.Checked.ToString().ToLower() == "true" ? "1" : "0";
cfa.Save();
// 刷新命名节,在下次检索它时将从磁盘重新读取它。记住应用程序要刷新节点
ConfigurationManager.RefreshSection("appSettings");
//再次查看是否修改成功
System.Configuration.ConfigurationManager.AppSettings["IsExportLock"].ToString()