Salut !
Merci de ta réponse mais du coup read n'est plus assignée avant d'aller dans le while donc ça ne compile pas.
J'ai modifié le code sans ce problème mais il en apparaît un autre....
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.9.204.111/index_mjpg.html");
req.Credentials = new NetworkCredential("admin", "admin");
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);
PictureBox1.Size = bmp.Size;
PictureBox1.BackgroundImage = bmp;
}
}
catch (Exception z)
{
MessageBox.Show(z.ToString());
} |
Image bmp = Image.FromStream(stream1);
Le paramètre n'est pas valide ! une idée ?
Pourtant mon lien est bon, il marche dans un browser.
Partager