C# Uri图像绘制

C# Uri图像绘制,c#,winforms,C#,Winforms,我想从uri中提取项目,如:http://profile/imgpath/0234245222.jpg“,但我遇到错误,uri不受支持 我习惯于以字节的形式绘制项目图像,我从不从uri中绘制 请帮帮我 private int mouseIndex = -1; private void listBox1_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index == -1) return;

我想从uri中提取项目,如:http://profile/imgpath/0234245222.jpg“,但我遇到错误,uri不受支持

我习惯于以字节的形式绘制项目图像,我从不从uri中绘制

请帮帮我

    private int mouseIndex = -1;

    private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
    {
        if (e.Index == -1) return;
        Image avatarContact = null;
        Mycontact contact = (Mycontact)listBox1.Items[e.Index];

        Brush textBrush = SystemBrushes.WindowText;
        if (e.Index > -1)
        {
            // Drawing the frame
            if (e.Index == mouseIndex)
            {
                e.Graphics.FillRectangle(SystemBrushes.HotTrack, e.Bounds);
                textBrush = SystemBrushes.HighlightText;
            }
            else
            {
                if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
                {
                    e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
                    textBrush = SystemBrushes.HighlightText;
                }else{
                    e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
                }
                // Drawing the Avatar Image
                if (contact.P_AVATAR_IMAGE != null)
                {
                    // displaying avatar picture
                    // if byte image
                    //MemoryStream stream = new MemoryStream(contact.P_AVATAR_IMAGE);
                    //avatarContact = Image.FromStream(stream );


                }
                else
                {
                    // if the contact has no avatar image, we can use a default one
                    if (contact.P_GENDER == "male") avatarContact = defaultMaleAvatar;
                    if (contact.P_GENDER == "female") avatarContact = defaultFemaleAvatar;
                }
                e.Graphics.DrawImage(avatarContact, e.Bounds.Left -2, e.Bounds.Top - 2, 50,40);

            }
        }
   }
看看这个,他们建议这样做

 Uri uri = new Uri("http://profile/imgpath/0234245222.jpg");
 WebRequest request = HttpWebRequest.Create(uri);
 WebResponse response = request.GetResponse();
 Stream stream = response.GetResponseStream();
 Image image = Image.FromStream(stream);

我的C#不是未知的WebRequest!,需要我添加哪个参照物吗?url中的
profile
是什么?这真的是你的领域吗?