private static void DownImageAndSave(string url) { if (!string.IsNullOrEmpty(url)) { string text = WebImageHelper.GetImageFileName(url); FileEx.DeleteWithoutException(text); using (WebClient webClient = new WebClient()) { try { webClient.DownloadFile(url, text); } catch (Exception e) { Log.Exception(e); Log.Info("无法下载图片,url=" + url); } } try { BitmapImageEx.ResizeImageAndSave(text, 300); } catch (Exception e2) { Log.Exception(e2); } } }
private static BitmapImage ReadImageFromCachedFile(string url) { BitmapImage img = null; lock (_synobj) { try { string filename = WebImageHelper.GetImageFileName(url); img = BitmapImageEx.CreateFromFile(filename, 3); } catch (Exception e) { Log.Exception(e); } } return(img); }