当我想在通过蓝牙连接的打印机上打印时,我遇到了一些奇怪的麻烦 . 当我运行我的程序时,我收到错误消息:
System.IO.IOException:找不到元素 . *(我希望它很好翻译)v System.IO.Ports.InternalResources.WinIOError(Int32 errorCode,String str)v System.IO.Ports.SerialStream..ctor(String portName,Int32 baudRate,Parity parity,Int32 dataBits,StopBits stopBits,Int32 readTimeout,Int32 writeTimeout,Handshake handshake,Boolean dtrEnable,Boolean rtsEnable,Boolean discardNull,Byte parityReplace)
代码是:
SerialPort port = new SerialPort();
port.PortName = listBox.SelectedItem.ToString();
port.BaudRate = 9600;
port.Parity = Parity.None;
port.StopBits = StopBits.One;
port.DtrEnable = true;
port.RtsEnable = true;
if (port.IsOpen)
port.Close();
try
{
port.Open();
port.Write("Test.");
port.Close();
}
catch (Exception ex)
{
textBox.Text = ex.ToString();
}
问题是,当我在Win 8 / 8.1上运行此应用程序时,它打印正常 . 当我在Windows 10上试用它时,我收到了这条消息 . 有没有人可以给我任何建议?谢谢 .