![](/img/trans.png)
[英]Icon not shown after file association with clickonce in OpenFileDialog
[英]Cef - upload file without shown OpenFileDialog
我需要一種方法來選擇某些文件而不顯示OpenFileDialog。
是的,我知道CEF並不是使sth自動化的最佳方法,但是我需要使用CEF做到這一點。
我發現這可能從2014年開始出現: https : //github.com/cefsharp/CefSharp/pull/342/commits/c11fe8e4e97179ff4073208c13f9ff29e61bab79
在這個提交中添加了覆蓋文件瀏覽對話框結果的功能...但是我仍然不明白如何使用此功能...
而且我發現了用法示例,但是不起作用:
using System.Collections.Generic;
using System.IO;
namespace CefSharp.Example
{
public class TempFileDialogHandler : IDialogHandler
{
public bool OnFileDialog(IWebBrowser browser, string title, string defaultFileName, List<string> acceptTypes, out List<string> result)
{
result = new List<string> { Path.GetRandomFileName() };
return true;
}
}
}
它不會向我顯示錯誤,即目前OnFileDialog中的IDialogHandler具有另一個參數(無結果)。
當前參數列表為:
public bool OnFileDialog(IWebBrowser browserControl, IBrowser browser, CefFileDialogMode mode, string title, string defaultFilePath, List<string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback)
有人能幫我嗎?
我正在使用最新的CEFsharp:63.0.3
public class TempFileDialogHandler : IDialogHandler
{
string[] _filePath;
public TempFileDialogHandler(params string[] filePath)
{
_filePath = filePath;
}
public bool OnFileDialog(IWebBrowser browserControl, IBrowser browser, CefFileDialogMode mode, string title, string defaultFilePath, List<string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback)
{
callback.Continue(0, _filePath.ToList());
return true;
}
}
和用法:
Browser.DialogHandler = new TempFileDialogHandler(files);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.