Réponse acceptée !
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://hostname");
req.Credentials = new NetworkCredential("userName", "Password");
byte[] buffer = new byte[100000];
int read, total = 0;
WebResponse resp = req.GetResponse();
Stream stream = resp.GetResponseStream();
while ((read = stream.Read(buffer, total, 1000)) != 0)
total += read;
if (total > 0)
{
Bitmap bmp = (Bitmap)Bitmap.FromStream(new MemoryStream(buffer, 0, total));
pictureBox1.Size = bmp.Size;
pictureBox1.BackgroundImage = bmp;
}
|