c#get和post请求(一)Get一张图

private Image getUrlImage(string url)
        {
            WebResponse result = null;
            Image  rImage = null;
            try
            {
                WebRequest request = WebRequest.Create(url);
                result = request.GetResponse();
                Stream stream = result.GetResponseStream();
                BinaryReader br = new BinaryReader(stream);
                byte[] rBytes = br.ReadBytes(1000000);
                br.Close();
                result.Close();
                MemoryStream imageStream = new MemoryStream(rBytes, 0, rBytes.Length);
                imageStream.Write(rBytes, 0, rBytes.Length);
                rImage = Image.FromStream(imageStream, true);
                imageStream.Close();
            }
            catch (Exception c)
            {
                //MessageBox.Show(c.Message);
            }
            finally
            {
                if (result != null) result.Close();
            }
            return rImage;

        }
profilePic = getUrlImage("https://graph.facebook.com/" + me.id + "/picture");

 

c#get和post请求(一)Get一张图

上一篇:vector转数组


下一篇:[Delphi]无边框窗口最大化不挡任务栏方法