标签:
string src = temppartsrc + "." + pictype;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(src);
request.AllowAutoRedirect = true;
WebProxy proxy = new WebProxy();
proxy.BypassProxyOnLocal = true;
proxy.UseDefaultCredentials = true;
request.Proxy = proxy;
WebResponse response = request.GetResponse();
string virthpath = "";
using (Stream stream = response.GetResponseStream())
{
using (MemoryStream ms = new MemoryStream())
{
Byte[] buffer = new Byte[1024];
int current = 0;
while ((current = stream.Read(buffer, 0, buffer.Length)) != 0)
{
ms.Write(buffer, 0, current);
}
byte[] arry = ms.ToArray();
virthpath = "./image/" + DateTime.Now.ToString("yyyyMMddhhmmss") + "." + pictype;
string path = Server.MapPath(virthpath);
File.WriteAllBytes(path, arry);
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/yangangwuwuyangang/article/details/46770613