Click here to Skip to main content
15,884,879 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In a WPF project I use the method

C#
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

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.
 
Share this answer
 
Comments
Leo Chapiro 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.
Leo Chapiro 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" />
Leo Chapiro 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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900