标签:web 发送请求 ons ati post请求 read tar 2.3 sys
string path = System.Windows.Forms.Application.StartupPath+"\\1.jpg";//下载到的地址+文件名
// 设置参数
HttpWebRequest request = WebRequest.Create("http://172.31.2.7:3480/resource/root/服务券/生日礼/10月/twg160922_392x120.jpg") as HttpWebRequest;
//发送请求并获取相应回应数据
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
//直到request.GetResponse()程序才开始向目标网页发送Post请求
Stream responseStream = response.GetResponseStream();
//创建本地文件写入流
Stream stream = new FileStream(path, FileMode.Create);
byte[] bArr = new byte[1024];
int size = responseStream.Read(bArr, 0, (int)bArr.Length);
while (size > 0)
{
stream.Write(bArr, 0, size);
size = responseStream.Read(bArr, 0, (int)bArr.Length);
}
stream.Close();
responseStream.Close();
标签:web 发送请求 ons ati post请求 read tar 2.3 sys
原文地址:http://www.cnblogs.com/zengwangjing/p/7649904.html