无法打开串口COM1

时间:2018-02-27 12:08:45

标签: .net printing serial-port

我试图向COM1发送字节,COM1上附有打印机。

我有以下内容:

foreach (var portName in SerialPort.GetPortNames())
{
    WriteLine(portName);
}
var mPort = new SerialPort();
if (mPort.IsOpen)
    mPort.Close();
mPort.PortName = "COM1";
mPort.Open();

" COM1"由SerialPort.GetPortNames返回,但是,当我到达mPort.Open()行时,我得到ArgumentException

The given port name does not start with COM/com or does not resolve to a valid serial port.

0 个答案:

没有答案