J
jwgoerlich
Hello group,
I am working with images on a website which uses cookie-based
authentication. I would like to programmatically download and save the
image. I am using a webBrowser rather than a HttpWebRequest because of
the authentication.
My code is as follows:
webBrowser.Url = new Uri("http://www.somewhere.com/images/
myimage.png");
do
{
System.Threading.Thread.Sleep(100);
} while (webBrowser.IsBusy || !webBrowser.DocumentStream.CanRead);
Bitmap i = new Bitmap(webBrowser.DocumentStream);
i.Save("myimage.png", ImageFormat.Png);
When I feed the DocumentStream into the new image, however, the code
fails with "Parameter is not valid."
What is the best way to download an image from the web?
Thanks in advance,
J Wolfgang Goerlich
I am working with images on a website which uses cookie-based
authentication. I would like to programmatically download and save the
image. I am using a webBrowser rather than a HttpWebRequest because of
the authentication.
My code is as follows:
webBrowser.Url = new Uri("http://www.somewhere.com/images/
myimage.png");
do
{
System.Threading.Thread.Sleep(100);
} while (webBrowser.IsBusy || !webBrowser.DocumentStream.CanRead);
Bitmap i = new Bitmap(webBrowser.DocumentStream);
i.Save("myimage.png", ImageFormat.Png);
When I feed the DocumentStream into the new image, however, the code
fails with "Parameter is not valid."
What is the best way to download an image from the web?
Thanks in advance,
J Wolfgang Goerlich