日期:2014-05-18 浏览次数:20805 次
FileStream fs = new FileStream("c:\\CP.xml",FileMode.Open); // 使用文件流构造一个二进制读取器将基元数据读作二进制值 byte[] imageBuffer = new byte[fs.Length]; HttpWebRequest myRequest =(HttpWebRequest)WebRequest.Create("你要指向的服务器地址"); myRequest.Method = "POST"; myRequest.ContentType="text/plainsInput"; myRequest.ContentLength = imageBuffer.Length; MessageBox.Show(imageBuffer.Length.ToString()); Stream newStream=myRequest.GetRequestStream(); const int size = 1000; int total,rdby,len,num; total=imageBuffer.Length; rdby=0; len=0; num=0; len =fs.Read(imageBuffer,0,total) ; //将读取的数据发送到对应的计算机 newStream.Write(imageBuffer, 0,len);