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 }