我正在使用vb.net应用程序,我曾经通过com1端口打印我的代码是这样的:
Using comPort As SerialPort = My.Computer.Ports.OpenSerialPort("COM1")
Dim fs As New IO.FileStream(AppPath & "\Print Files\TempBloodBag.zpl", IO.FileMode.Open)
Dim br As New IO.BinaryReader(fs)
Dim fileBytes() As Byte = br.ReadBytes(CInt(br.BaseStream.Length))
br.Close()
fs.Close()
comPort.Write(fileBytes, 0, fileBytes.Length)
End Using
但是我的新PC没有com端口..所以我只是尝试使用以下代码..但是没有打印任何东西..
Dim ipadress As String = "10.15.40.139"
Dim port As Integer = 9100
Dim client As New System.Net.Sockets.TcpClient
client.Connect(ipadress, port)
'Write ZPL String to Connection
Dim fs As New IO.FileStream(AppPath & "\Print Files\TempBloodBag.zpl", IO.FileMode.Open)
Dim br As New IO.BinaryReader(fs)
Dim fileBytes() As Byte = br.ReadBytes(CInt(br.BaseStream.Length))
br.Close()
fs.Close()
Dim writer As New System.IO.StreamWriter(client.GetStream())
writer.Write(fileBytes)
writer.Flush()
'Close Connection
writer.Close()
client.Close()