1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| try
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://192.168.1.77/cgi-bin/video.jpg:80");
req.Credentials = new NetworkCredential("admin", "azerty");
byte[] buffer = new byte[100000];
int read, total = 0;
WebResponse resp = req.GetResponse();
Stream stream;
using (stream = resp.GetResponseStream())
{
while ((read = stream.Read(buffer, total, 1000)) != 0)
total += read;
}
if (stream != null)
{
MessageBox.Show("stream non null");
}
if (total > 0)
{
MemoryStream stream1 = new MemoryStream(buffer, 0, total);
Image bmp = Image.FromStream(stream1);
BoxCam1.Size = bmp.Size;
BoxCam1.BackgroundImage = bmp;
}
}
catch (Exception z)
{
MessageBox.Show(z.ToString());
} |
Partager