我正在尝试使用简单的写入命令将字符串写入 Com5 上的内部打印机。WriteLine 方法打印得很好,但 Write 不会。下面是我正在调用的代码。它只是调用 .NET 函数的简单包装函数。
public static void Write(string printString)
{
//intialize the com port
SerialPort com5 = new SerialPort("COM5", 9600, Parity.None, 8, StopBits.One);
com5.Handshake = Handshake.XOnXOff;
com5.Open();
//write the text to the printer
com5.Write(printString);
Thread.Sleep(100);
com5.Close();
}
public static void WriteLine(string printString)
{
//intialize the com port
SerialPort com5 = new SerialPort("COM5", 9600, Parity.None, 8, StopBits.One);
com5.Handshake = Handshake.XOnXOff;
com5.Open();
//write the text to the printer
com5.WriteLine(printString);
Thread.Sleep(100);
com5.Close();
}