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");