日期:2014-05-18 浏览次数:20823 次
static void Main(string[] args) { TcpClient tcp = new TcpClient(); tcp.Connect("127.0.0.1", 9000); NetworkStream str = tcp.GetStream(); byte[] byy=new byte[8*1024]; System.IO.FileStream fs = new System.IO.FileStream("(1).jpeg", System.IO.FileMode.Create, System.IO.FileAccess.Write); while(true) { int a = str.Read(byy, 0, byy.Length); if (a > 0) fs.Write(byy, 0, a); else break; } fs.Close(); str.Close(); string s = Console.Read().ToString(); }
IPAddress ip = IPAddress.Parse("127.0.0.1"); TcpListener conn = new TcpListener(ip, 9000); conn.Start(); TcpClient tcp = conn.AcceptTcpClient(); FileStream fs = File.OpenRead("2012-08-04_15_58_25.Jpeg"); byte[] fsdata = new byte[fs.Length]; NetworkStream str = tcp.GetStream(); str.Write(fsdata, 0, fsdata.Length); str.Close(); fs.Close(); string s = Console.Read().ToString();