我编写了这段代码来更改serialport
名称:
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
serialPort1.PortName = (string)comboBox1.SelectedValue;
}
catch (Exception)
{
MessageBox.Show("The SerialPorts's Name Does Not Change !! ");
}
}
结果是我得到一个Exception
. 的SerialPort
名字永远不会改变。