Winform 修改并保存配置文件

            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            config.AppSettings.Settings["host"].Value = txtHost.Text;
            config.AppSettings.Settings["port"].Value = nudPort.Value.ToString();
            config.AppSettings.Settings["user"].Value = txtUser.Text;
            config.AppSettings.Settings["password"].Value = txtPwd.Text;
            config.Save();
            if (MessageBox.Show("重新启动程序以应用新配置", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
                Application.Restart();

你可能感兴趣的:(user,WinForm)