System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["dbHost"].Value = txtHost.Text.ToString();
config.AppSettings.Settings["dbName"].Value = txtName.Text.ToString();
config.AppSettings.Settings["dbUser"].Value = txtUser.Text.ToString();
config.AppSettings.Settings["dbPass"].Value = txtPass.Text.ToString();
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
当我重新打开应用程序时,我在运行 - 得到一个空白文本的app.config不保存我的配置
应用程序或用户级别的设置是?如果是应用程序,那么这是我相信的预期行为,因为这些行为在运行时无法更改。 – KingCronus