Click here to Skip to main content
14,328,670 members
Rate this:
Please Sign up or sign in to vote.
See more:
In a WPF project I use the method

webBrowser.Navigate(strUrl);


to get a PNG picture from the server. Following dialog appears:

"File download" / "Do you want to open or save this file?"

How to get rid of this dialog by dowloading the picture silently?

What I have tried:

I've tried to use some Registry settings in
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl
such as "FEATURE_DOWNLOAD_PROMPT_META_CONTROL" and so long ...
Posted
Updated 3-Apr-19 0:18am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Why not using the System.Net.WebClient?

e.g.
var webClient = new WebClient();
webClient.DownloadFile(new Uri("http://www.google.de//images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"), @"c:\temp\google.png");

will download the Google logo and save it as google.png on your hard drive without asking any questions.
   
Comments
_duDE 3-Apr-19 7:51am
   
Thank you for the answer! I need to SHOW this picture in the WebBrowser control. This control is basically the simple IE window, that can both things: download AND show the picture.
The idea to use WebClient is nice (+1) but not exactly what I need :(
TheRealSteveJudge 3-Apr-19 8:07am
   
You're welcome. I just tried this:
MyWebBrowser.Navigate("http://www.google.de//images/branding/googlelogo/2x/googlelogo_color_272x92dp.png");

and it showed the Google logo in the web browser control without any dialogue.
_duDE 3-Apr-19 10:58am
   
Yes, I have this problem only on some systems: it may be a strange Registry setting but I cannot find which exactly ...
Richard Deeming 4-Apr-19 11:38am
   
Do you really need to show it in a WebBrowser control? Or do you just want to show it somehow?

Both the WPF Image control and the BitmapImage class can load images directly from a URL.

Eg:
<Image Source="http://www.google.de/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" />
_duDE 5-Apr-19 4:21am
   
Thank you, Richard! Nice idea, I will try it!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100