修改config文件

保存事件#region 保存事件
private void button1_Click(object sender, EventArgs e)
{
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(Application.StartupPath+"\\Received.exe");
//获取appSettings节点
AppSettingsSection appSection = (AppSettingsSection)config.GetSection("appSettings");
appSection.Settings["PortName"].Value = this.textBox1.Text;
appSection.Settings["BaudRate"].Value = this.comboBox1.Text;
appSection.Settings["DataBits"].Value = this.comboBox2.Text;
appSection.Settings["Parity"].Value = this.comboBox3.Text;
appSection.Settings["StopBits"].Value = this.comboBox4.Text;
config.Save();
ConfigurationManager.RefreshSection("appSettings");
this.Close();
}
#endregion
浙公网安备 33010602011771号