/// <summary> /// Loads the image from the given path /// </summary> /// <param name="path">Path of image that should be used for this banner</param> /// <returns>True if successful, false otherwise</returns> protected Image LoadImage(String path) { try { WebClient client = new CompressionWebClient(); byte[] imgData = client.DownloadData(path); MemoryStream ms = new MemoryStream(imgData); Image img = Image.FromStream(ms, true, true); return img; } catch (Exception ex) { Log.Error("Error while loading image ", ex); return null; } }
protected byte[] DownloadData(string url) { using (WebClient webClient = new CompressionWebClient { Encoding = Encoding.UTF8 }) return webClient.DownloadData(url); }