So, I'm trying to get an image from the webbrowser in C#
and for some reasons every second / third time it does it, it return a blank picture with the right canvas, instead of just getting the image, and I cant just download it, unfortunately thats not possible, so thats why im doing it this way :)

Bitmap bitmap = new Bitmap(webBrowser1.Width, webBrowser1.Height);
webBrowser1.DrawToBitmap(bitmap, new Rectangle(0, 0, webBrowser1.Width, webBrowser1.Height));
Bitmap pic = bitmap.Clone(new Rectangle(711, 431, 873 - 711, 472 - 431), bitmap.PixelFormat);
pic.Save("image.png");
pic.Dispose();
bitmap.Dispose();

If you want to download image which is accessed thru webbrowser. There is some easiest way to do it. If you view any image in webbrower control, it will cached locally your machine. You just need to find the correct path, make a clone and finally save it in your required folder.

There is some method called FindUrlCacheEntries to retrieve local temp image path. But i don't know which dll :)

If you want to download image which is accessed thru webbrowser. There is some easiest way to do it. If you view any image in webbrower control, it will cached locally your machine. You just need to find the correct path, make a clone and finally save it in your required folder.

There is some method called FindUrlCacheEntries to retrieve local temp image path. But i don't know which dll :)

Thank you! Ill look into it right away :D!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.