I know that you specifically asked for WinForms solution, but this may help some others. For the .NET 4.0 console application, none of them worked for me. So I used the following and worked:
private static void UpdateSetting(string key, string value) { Configuration configuration = ConfigurationManager. OpenExeConfiguration(Assembly.GetExecutingAssembly().Location); configuration.AppSettings.Settings[key].Value = value; configuration.Save(); ConfigurationManager.RefreshSection("appSettings"); }
Jahmic
source share