displaying url image in picturebox .NET CF

Sep 17 2009 3:58 AM
hi,
I am trying to develop an application using C#.
The problem i am facing is i am unable to display an url image in picturebox.
each time i try , m_bmpdata = null.... i can retrieve the url image height, width etc but the pict is not displaying. below is the code i m trying. Any help or hint will be very helpful. I been trying for the past 2 days.

                   HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(thumbnail.Url);
                   request.Timeout = 5000; // 5 seconds in milliseconds
                   request.ReadWriteTimeout = 20000; // allow up to 20 seconds to elapse
                   HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                   Stream ms = response.GetResponseStream();
                   using (MemoryStream ms2 = new MemoryStream())
                    {
                        int bytes = 0;
                        byte[] temp = new byte[4096];
                        while ((bytes = ms.Read(temp, 0, temp.Length)) != 0)
                        ms2.Write(temp, 0, bytes);
                        test = new Bitmap(ms2);
                        //response.BinaryWrite(ms2.ToArray());
                    }
                    pictureBox2.Height = test.Height;
                    pictureBox2.Width = test.Width;
                    pictureBox2.Image = test;


thank you very much for any help... a big thanks in advance.. if there is any better do  inform me... thank you thank you

Answers (4)