下载url地址的图片

// string url = "https://api.weixin.qq.com/cgi-bin/media/get?access_token=cNaaMfvhpb1vmcVRXRAdIjRX3eUFsk1sRVrbOaPkR-8Gbli4xJE22sI9uLaf3q_aCIesyUtZ7KC4WvOKN9XquxWCHviW5yqMDJxojm-MMHE&media_id=wcrGxYBc_CotfNILfPtIPZNZS8N4GGhSpAP561qKY1s2AWYZXgPAD6dekWgCrHjK";

string url = "http://mmbiz.qpic.cn/mmbiz/PwIlO51l7wuFyoFwAXfqPNETWCibjNACIt6ydN7vw8LeIwT7IjyG3eeribmK4rhibecvNKiaT2qeJRIWXLuKYPiaqtQ/0";
string path = @"D:\5555555555555555555555555.jpg";
// string file = string.Empty;
string content = string.Empty;
string strpath = string.Empty;
string savepath = string.Empty;


HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);

req.Method = "GET";
using (WebResponse wr = req.GetResponse())
{
HttpWebResponse myResponse = (HttpWebResponse)req.GetResponse();
strpath = myResponse.ResponseUri.ToString();
WebClient mywebclient = new WebClient();
savepath = Server.MapPath("Images") + "\\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + (new Random()).Next().ToString().Substring(0, 4) + ".jpg";
try
{
mywebclient.DownloadFile(strpath, savepath);
// file = savepath;
}
catch (Exception ex)
{
savepath = ex.ToString();
}

}
// return file;

// WebClient WebClient = new WebClient();

//myWebClient.DownloadFile(myStringWebResource,fileName);
// WebClient.DownloadFile(address, "D::\\deeeeeeeeeeeeedd.png");
// Fcity.Core.FileSources.ChangeImageSize("D:\\QQ截图20141205121451.png", "D:\\ddd.png", 1000, 1000, ImageFormat.Jpeg);

return;

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。