强制CEFSharp下载而不显示对话框 [英] Force CEFSharp to download without showing dialog
问题描述
我有一个带有CEFSharp的WPF应用程序,它是一个Web浏览器,当我单击下载链接时,它会显示一个对话框并询问我要将文件保存在哪里?
我该如何保存?强制Web浏览器下载任何文件而不显示对话框?
我想创建类似Google chrome的东西。因此,当您单击下载链接时,它将把文件下载到默认路径(通常在文档/下载中)
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源代码,请告诉更多详细信息,因为我找到了一些解决方案,但没有完整的示例,只是一部分代码!
谢谢。
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 GitHub存储库中有一个示例
There is an example in the main CefSharp GitHub repository
此搜索指向相关代码位: https://github.com/cefsharp/CefSharp/search?q=DownloadHandler&type=Code&utf8=%E2%9C%93
This search points to the relevant code bits: https://github.com/cefsharp/CefSharp/search?q=DownloadHandler&type=Code&utf8=%E2%9C%93
您会在 CefSharp.Example
项目中看到常见的示例处理程序,这两个实例都从 CefSharp.Example.WinForms实例化。 code>和
CefSharp.Example.Wpf
项目。自从我尝试使用WinForms并没有多久以来,我就对WPF并不确定,但是快速浏览一下它就可以正常工作。如果不是,那是一个需要修复的错误!
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!
如果执行 IDownloadHandler
的搜索,则应参阅以下文档:接口。听起来您想设置 showDialog
参数设置为 false
。
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
.
这篇关于强制CEFSharp下载而不显示对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!