View Code
bool isModified = false; 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");