WebClient 下载图片(文件)

 1 public static string SaveImage(string url, string newfilename)
 2 {
 3       WebClient mywebclient = new WebClient();
 4       try
 5       {
 6           mywebclient.DownloadFile(url, ConfigurationManager.AppSettings["SaveImgPath"] +"/" + newfilename);
 7       }
 8       catch (IOException ex)
 9       {
10           throw new Exception("未找到图片:" + url + "   Message:" + ex.Message);
11       }
12       catch (Exception ex)
13       {
14           throw new Exception("未找到图片:" + url + "   Message:" + ex.Message);
15       }
16       return newfilename;
17 }
原文地址:https://www.cnblogs.com/grom/p/9327634.html