wpf 强制 CEFSharp 下载而不显示对话框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28565319/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Force CEFSharp to download without showing dialog
提问by Tour Looking
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")
我有一个带有 CEFSharp 的 WPF 应用程序,它是一个 Web 浏览器,当我单击下载链接时,它会显示一个对话框并询问我要将文件保存在哪里?
如何强制 Web 浏览器下载任何文件而不显示对话框?我想创建一些类似谷歌浏览器的东西。因此,当您单击下载链接时,它会将文件下载到默认路径(通常位于“文档/下载”中)
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.
现在我如何在我的应用程序中实现它?
如果我需要更改 CEFSharp 源代码,请告诉更多详细信息,因为我找到了一些解决方案,但没有完整的示例,只有一部分代码!谢谢你。
采纳答案by jornh
There is an example in the main CefSharp GitHub repository
主 CefSharp GitHub 存储库中有一个示例
This search points to the relevant code bits: https://github.com/cefsharp/CefSharp/search?q=DownloadHandler&type=Code&utf8=%E2%9C%93
此搜索指向相关代码位:https: //github.com/cefsharp/CefSharp/search?q=DownloadHandler&type=Code &utf8=%E2%9C%93
You see the common example handler in the CefSharp.Exampleproject gets instantiated from both the CefSharp.Example.WinFormsand CefSharp.Example.Wpfprojects. 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!
您会看到项目中的常见示例处理程序CefSharp.Example从CefSharp.Example.WinForms和CefSharp.Example.Wpf项目中实例化。自从我尝试使用 WinForms 后不久,我对 WPF 不太确定,但快速浏览一下它看起来很实用。如果不是,那就是一个需要修复的错误!
If you perform a search for IDownloadHandleryou should see the documentation of the interface. It sounds like in your case you want to set the showDialogparameter to false.
如果您执行搜索,IDownloadHandler您应该看到界面的文档。在您的情况下,听起来您想将showDialog参数设置为false.

