下载图片

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;
}
}

上一篇:C# FileStream StreamReader 读取TXT数据后删除最后一行


下一篇:C#如何读取包含普通和XML文本元素的单个文件