110,538
社区成员
发帖
与我相关
我的任务
分享
NetworkStream ns = Client.GetStream();
FileStream fs = new FileStream(FileName, FileMode.Open);
byte[] imagedata = new byte[4096];
while ( fs.Read(imagedata, 0, 4096) != 0)
{
ns.Write(imagedata, 0, imagedata.Length);
ns.Flush();
imagedata = new byte[4096];
}
fs.Close();
ns.Close();
Client.Close();
TcpClient client = listener.AcceptTcpClient();
NetworkStream ns = client.GetStream();
FileStream filestream = new FileStream(Application.StartupPath + "\\test.jpg", FileMode.OpenOrCreate, FileAccess.Write);
byte[] reccimg = new byte[2048];
int byteread = ns.Read(reccimg, 0, reccimg.Length);
while (byteread != 0)
{
filestream.Write(reccimg, 0, reccimg.Length);
ns.Flush();
byteread = ns.Read(reccimg, 0, reccimg.Length);
}
filestream.Close();
ns.Close();
client.Close();