问题
I have a WPF application with CEFSharp, it's a web browser, when I click on a download link it will show me a dialog and ask me where you want to save the file?
How can I force the web browser to download any files without showing dialog?
I want to create some thing like google chrome. so when you click on a download link it will download the file to a default path (usually it's in "Documents/Downloads")
now how can I implement this in my application?
if I need to change CEFSharp source code please tell more details because I found some solution but there aren't a complete example, there was just a part of code!
thank you.
回答1:
There is an example in the main CefSharp GitHub repository
This search points to the relevant code bits: https://github.com/cefsharp/CefSharp/search?q=DownloadHandler&type=Code&utf8=%E2%9C%93
You see the common example handler in the CefSharp.Example
project gets instantiated from both the CefSharp.Example.WinForms
and CefSharp.Example.Wpf
projects. It's not that long since I tried playing around with the WinForms one, I'm less sure about the WPF one but with a quick glance it looks functional. If not it's a bug that needs fixing!
If you perform a search for IDownloadHandler
you should see the documentation of the interface. It sounds like in your case you want to set the showDialog parameter to false
.
来源:https://stackoverflow.com/questions/28565319/force-cefsharp-to-download-without-showing-dialog