/// <summary> /// 下载远程图片 /// </summary> /// <param name="url"></param> /// <returns></returns> private Image GetImage(string url) { try { HttpWebRequest myrequest = WebRequest.Create(url) as HttpWebRequest; HttpWebResponse resp = (HttpWebResponse)myrequest.GetResponse(); if (resp.StatusCode == HttpStatusCode.OK) { Stream imgstream = resp.GetResponseStream(); return System.Drawing.Image.FromStream(imgstream); } else { return null; } } catch (WebException ex) { return null; } catch (Exception ex) { return null; } }
时间: 2024-12-17 03:00:12