110,538
社区成员
发帖
与我相关
我的任务
分享
string strFilePath = @"C:\" + prnVLZK.strLZKH + prnVLZK.NowJH.ToString() + ".Prn";
FileStream fs = new FileStream(strFilePath, FileMode.Open, FileAccess.Read);
//2、建立二进制读取流;指定读取的方式为Encoding.ASCII
BinaryReader brMyfile = new BinaryReader(fs, Encoding.ASCII);
brMyfile.BaseStream.Seek(0, SeekOrigin.Begin);
m_SendData = "LENG=" + fs.Length.ToString();
data = EncodingUTF8(m_SendData);
ns.Write(data, 0, data.Length);
int i = 0;
while (brMyfile.PeekChar() > -1)
{
//读取文件中的一个字符;
b1[0] = brMyfile.ReadByte();
try
{
ns.WriteByte(b1[0]);
}
catch(Exception ex)
{
;
}
i++;
}
m_ClientPrn = new TcpClient();
m_ClientPrn.Connect(m_Host, port);
rsPrn = new StreamReader(m_ClientPrn.GetStream());
wsPrn = m_ClientPrn.GetStream();
while (true)
{
int ch = wsPrn.ReadByte();
b1[0] = (Byte)ch;
i++;
if (i > fileLength)
break;
}