下载图片

public static bool Down_Load_Image(string url, string filePath)
{
try
{
DateTime now_dt = DateTime.Now;
WebClient client = new WebClient();
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | (SecurityProtocolType)0x300 | (SecurityProtocolType)0xc00;
//client.Proxy = null;
byte[] data = client.DownloadData(url);
FileStream fs = new FileStream(filePath, FileMode.Create);
fs.Write(data, 0, data.Length);
fs.Dispose();
fs.Close();
TimeSpan ts = DateTime.Now - now_dt;
return true;
}
catch (Exception ex)
{
return false;
}
}

原文地址:https://www.cnblogs.com/niyl/p/12220683.html