foreach (string key in ConfigurationManager.AppSettings)
{
if (key == "box")
{
isModified = true;
}
}
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (isModified)
{
config.AppSettings.Settings.Remove("box");
}
config.AppSettings.Settings.Add("box", txt_value.Text);
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
转载于:https://my.oschina.net/u/245212/blog/54382