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 }

 

posted on 2018-07-18 10:16  Grom  阅读(1077)  评论(0编辑  收藏  举报