So there is:
- CefSharp.Winforms
- Some site where there is a button Upload File, which opens OpenFileDialog
You open the site and click on the upload (manually). OpenFileDialog should NOT OPEN, but simply accept as a default address the file path.
This functionality was available in 2014: https://github.com/cefsharp/CefSharp/pull/342/commits/c11fe8e4e97179ff4073208c13f9ff29e61bab79
Then it was realized in the following way:
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; } } } after which the case should have been assigned to the browser instance:
Browser.DialogHandler = new TempFileDialogHandler(files); Now the list of parameters has changed and looks like this:
public bool OnFileDialog(IWebBrowser browserControl, IBrowser browser, CefFileDialogMode mode, string title, string defaultFilePath, List<string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback) That is, the ability to set a Result of our OpenFileDialog has been removed. I still need to implement it ...
So the question is: how to get around this and implement this opportunity now?
Preferably without using WinApi.
Example of a page with a button: https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_accept