public void DownloadImage(string url, string path)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.ServicePoint.Expect100Continue = false;
req.UserAgent = "Mozilla/6.0 (MSIE 6.0; Windows NT 5.1; Natas.Robot)";
req.Method = "GET";
//req.Headers.Add("Cookie", "_sessionID=9FBCB4630D3F4D04955FEA7FBF725533; JSESSIONID=0000YTOL3mownFwgaoun0nHB_gu:-1");
req.KeepAlive = true;
HttpWebResponse rsp = (HttpWebResponse)req.GetResponse();
System.IO.Stream stream = null;
try
{
// 以字符流的方式读取HTTP响应
stream = rsp.GetResponseStream();
Image.FromStream(stream).Save(path);
}
finally
{
// 释放资源
if (stream != null) stream.Close();
if (rsp != null) rsp.Close();
}
}