代码:
using System;
using System.Net;
using System.Threading;
using System.IO;
namespace nets
{
public class NetsServer
{
private TcpClient client;
private NetworkStream net;
private StreamReader sr;
private void run()
{
client=new TcpClient("127.0.0.1",999);
net=client.GetStream();
sr=new StreamReader(net,System.Text.Encoding.Unicode);
string str=sr.ReadLine();
int len=Convert.ToInt32(str);
string fname=sr.ReadLine();
FileStream fs=new FileStream("e:\\"+str,FileMode.Create,FileAccess.Write);
for(int i=0;i<len;i++)
{
fs.WriteByte((byte)net.ReadByte());
fs.Flush();
}
fs.Close();
net.Close();
MessageBox.Show("OK");
}
}
}