Reputation: 1070
lately I got a problem on using .net WebBrowser control. when redirect to a file downloading, the WebBrowser control popup the SaveFileDialog, I don't know if there is a way avoid this to let me choose a filename and save it to some location.
Thanks for any helps.
Upvotes: 2
Views: 3037
Reputation: 15271
You can install your own custom download manager by adding IServiceProvider to your WebBrowserSiteBase-derived class, which needs to be constructed in your webbrowser-derived class as the return value of the WebBrowser.CreateWebBrowserSiteBase virtual function.
In your download manager implementation you can write the file saving code. See https://code.msdn.microsoft.com/windowsdesktop/CSIEDownloadManager-8ab5d910 for an example to grab the download url. If the download url requires login, you need to grab session cookies. Check http://vbmhwb.sourceforge.net/ for an example.
Upvotes: 1
Reputation: 1500665
You could handle the Navigating
event, detect that it's a file download, make the request yourself with HttpWebRequest
or WebClient
, and cancel the navigating event within the handler.
Upvotes: 4