/// <summary>如果指定的Url正确则返回Url字符串,否则返回空字符串</summary> /// <param name="url">指定的Url</param> /// <returns>如果指定的Url正确则返回Url字符串,否则返回空字符串</returns> public static string GetUrls(string url) { if (Often.IsUrl(url)) { if (url.IndexOf("/", 8) == -1) { url += "/"; } return(url); } return(""); }
/// <summary>根据url或本地路径返回图片对象</summary> /// <param name="path">url或本地路径</param> /// <returns>根据url或本地路径返回图片对象</returns> public static Image GetImage(string path) { try { if (Often.IsUrl(path)) { Uri uri = new Uri(path); WebRequest req = WebRequest.Create(uri); WebResponse resp = req.GetResponse(); Stream str = resp.GetResponseStream(); Image img = Image.FromStream(str); return(img); } else if (File.Exists(path)) { Image img = Image.FromFile(path); return(img); } } catch { } return(null); }