I found some code examples that update the keys in the app.config file when running without error and not updating, why the code does not update, see my code
file app.config
[CODE]
[/CODE]
[CODE]
private void cmdUpdate_Click(object sender, EventArgs e)
{
EditAppSetting("LogFile", "D:\Office2010");
}
public static void EditAppSetting(string key, string value)
{
try
{
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings[key].Value = value;
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
}
catch (Exception ex)
{
MessageBox.Show("Error update file App.config: " + ex.Message, "Thông báo ki?m tra !", MessageBoxButtons.OK, MessageBoxIcon.Question);
}
}
[/CODE]
Sachin SinghPosted Jun 17, 2021, 7:12 AM