您当前的位置:首页 > ASP.NET > 文章详情

c#获取远程图片文件流代码

2019-03-084978人围观
c#
/// <summary> /// 获取图片流 /// </summary> /// <param name="url">图片URL</param> /// <returns></returns> public static Stream GetRemoteImage(string url) { HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.Method = "GET"; request.ContentLength = 0; request.Timeout = 20000; HttpWebResponse response = null; try { response = (HttpWebResponse)request.GetResponse(); return response.GetResponseStream(); } catch { return null; } }   直接调用就好了.

文章评论

热门评论
暂无评论