hi dear
use below function
private bool savesattings(string key, string value)
{
try
{
System.Configuration.Configuration lobjconfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
lobjconfig.AppSettings.Settings.Remove(key);
lobjconfig.AppSettings.Settings.Add(key, value);
lobjconfig.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
return true;
}
catch
{
return false;
}
}
private void btnChange_Click(object sender, EventArgs e)
{
savesattings("DemoKey", "MyValue");
}