如何在c#winforms中的app.config文件上动态更新应用程序设置键值对

如何在c#winforms中的app.config文件上动态更新应用程序设置键,值。 键,值列在下面

     

 Configuration configuration = ConfigurationManager. OpenExeConfiguration(Assembly.GetExecutingAssembly().Location); configuration.AppSettings.Settings["logPath"].Value = DateTime.Now.ToString("yyyy-MM-dd"); configuration.Save(); ConfigurationManager.RefreshSection("appSettings"); 

我相信这就是你要找的东西:

 using System.Configuration; Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings["isScreenCaptureMode"].Value = "true"; config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("appSettings");