public bool OnFileDialog(IWebBrowser webBrowser, IBrowser browser, CefFileDialogMode mode, CefFileDialogFlags flags, string title, string defaultFilePath, List <string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback) { var args = new DialogRequestedEventArgs { Element = ToElement(mode), InitialPath = defaultFilePath, Operation = ToOperation(mode), Title = title }; Task.Run(() => { DialogRequested?.Invoke(args); using (callback) { if (args.Success) { callback.Continue(selectedAcceptFilter, new List <string> { args.FullPath }); } else { callback.Cancel(); } } }); return(true); }
protected override bool OnFileDialog(CefBrowser browser, CefFileDialogMode mode, string title, string defaultFilePath, string[] acceptFilters, int selectedAcceptFilter, CefFileDialogCallback callback) { if (mode == (CefFileDialogMode.Save | CefFileDialogMode.OverwritePromptFlag | CefFileDialogMode.HideReadOnlyFlag)) { var saveFileDialog = new SaveFileDialog(); saveFileDialog.FileName = defaultFilePath; //saveFileDialog.Filter = string.Join("Supported Files|*", acceptFilters); if (saveFileDialog.ShowDialog() == DialogResult.OK && saveFileDialog.FileName != "") { callback.Continue(selectedAcceptFilter, saveFileDialog.FileNames); } } else if (mode == (CefFileDialogMode.OpenFolder | CefFileDialogMode.OverwritePromptFlag | CefFileDialogMode.HideReadOnlyFlag)) { var dialog = new FolderBrowserDialog(); if (dialog.ShowDialog() == DialogResult.OK && dialog.SelectedPath != "") { callback.Continue(selectedAcceptFilter, new string[] { dialog.SelectedPath }); } } else if (mode == (CefFileDialogMode.OverwritePromptFlag | CefFileDialogMode.HideReadOnlyFlag)) { var dialog = new OpenFileDialog(); dialog.Multiselect = mode == CefFileDialogMode.OpenMultiple; if (dialog.ShowDialog() == DialogResult.OK && dialog.FileName != "") { callback.Continue(selectedAcceptFilter, dialog.FileNames); } } //else callback.Cancel(); return(base.OnFileDialog(browser, mode, title, defaultFilePath, acceptFilters, selectedAcceptFilter, callback)); }
private static FileDialogType ConvertDialogType(CefFileDialogMode mode) { return(mode switch { CefFileDialogMode.Open => Open, CefFileDialogMode.OpenMultiple => OpenMultiple, _ => Other });
protected override Boolean OnFileDialog(CefBrowser browser, CefFileDialogMode mode, String title, String defaultFileName, String[] acceptTypes, CefFileDialogCallback callback) { if (mode == CefFileDialogMode.Open || mode == CefFileDialogMode.OpenMultiple) { if (this.Client.HandleOpenFileDialog != null) { callback.Continue(this.Client.HandleOpenFileDialog(title, defaultFileName, acceptTypes)); return(true); } } else if (mode == CefFileDialogMode.Save) { if (this.Client.HandleSaveFileDialog != null) { callback.Continue(this.Client.HandleSaveFileDialog(title, defaultFileName, acceptTypes)); return(true); } } Log.Trace("DialogHandler.OnFileDialog( browser: {0}, mode: {1}, title: {2}, defaultFileName: {3}, acceptTypes: {4} )", browser.Identifier, Enum.GetName(typeof(CefFileDialogMode), mode), title, defaultFileName, String.Join(" ", acceptTypes)); return(false); //return base.OnFileDialog( browser, mode, title, defaultFileName, acceptTypes, callback ); }
public bool OnFileDialog(IWebBrowser browserControl, IBrowser browser, CefFileDialogMode mode, CefFileDialogFlags flags, string title, string defaultFilePath, List <string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback) { if (mode == CefFileDialogMode.Open || mode == CefFileDialogMode.OpenMultiple) { string allFilters = string.Join(";", acceptFilters.SelectMany(ParseFileType).Where(filter => !string.IsNullOrEmpty(filter)).Select(filter => "*" + filter)); using (OpenFileDialog dialog = new OpenFileDialog { AutoUpgradeEnabled = true, DereferenceLinks = true, Multiselect = mode == CefFileDialogMode.OpenMultiple, Title = "Open Files", Filter = $"All Supported Formats ({allFilters})|{allFilters}|All Files (*.*)|*.*" }){ if (dialog.ShowDialog() == DialogResult.OK) { string ext = Path.GetExtension(dialog.FileName)?.ToLower(); callback.Continue(acceptFilters.FindIndex(filter => ParseFileType(filter).Contains(ext)), dialog.FileNames.ToList()); } else { callback.Cancel(); } callback.Dispose(); } return(true); } else { callback.Dispose(); return(false); } }
public void RunFileDialog(CefFileDialogMode mode, string title, string defaultFileName, string[] acceptTypes, int selectedAcceptFilter, CefRunFileDialogCallback callback) { if (_browser != null) { _browser.GetHost().RunFileDialog(mode, title, defaultFileName, acceptTypes, selectedAcceptFilter, callback); } }
public bool OnFileDialog(IWebBrowser browser, CefFileDialogMode mode, string title, string defaultFileName, List <string> acceptTypes, out List <string> result) { result = new List <string> { Path.GetRandomFileName() }; return(true); }
public unsafe int OnFileDialog(cef_browser_t *browser, CefFileDialogMode mode, [Immutable] cef_string_t *title, [Immutable] cef_string_t *default_file_path, cef_string_list_t accept_filters, int selected_accept_filter, cef_file_dialog_callback_t *callback) { fixed(cef_dialog_handler_t *self = &this) { return(((delegate * unmanaged[Stdcall] < cef_dialog_handler_t *, cef_browser_t *, CefFileDialogMode, cef_string_t *, cef_string_t *, cef_string_list_t, int, cef_file_dialog_callback_t *, int >)on_file_dialog)(self, browser, mode, title, default_file_path, accept_filters, selected_accept_filter, callback)); } }
public bool OnFileDialog(IWebBrowser browserControl, IBrowser browser, CefFileDialogMode mode, string title, string defaultFilePath, List <string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback) { if (OwnerWebView.DisableFileDialogs) { return(true); } return(false); }
public bool OnFileDialog(IWebBrowser browserControl, IBrowser browser, CefFileDialogMode mode, string title, string defaultFilePath, List <string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback) { callback.Continue(selectedAcceptFilter, new List <string> { Path.GetRandomFileName() }); return(true); }
protected override bool OnFileDialog(CefBrowser browser, CefFileDialogMode mode, string title, string defaultFilePath, string[] acceptFilters, int selectedAcceptFilter, CefFileDialogCallback callback) { if (OwnerWebView.DisableFileDialogs) { return(true); } return(false); }
public bool OnFileDialog(IWebBrowser chromiumWebBrowser, IBrowser browser , CefFileDialogMode mode, CefFileDialogFlags flags , string title, string defaultFilePath , List <string> acceptFilters, int selectedAcceptFilter , IFileDialogCallback callback) { return(true); }
private FileSystemOperation ToOperation(CefFileDialogMode mode) { switch (mode) { case CefFileDialogMode.Save: return(FileSystemOperation.Save); default: return(FileSystemOperation.Open); } }
private FileSystemElement ToElement(CefFileDialogMode mode) { switch (mode) { case CefFileDialogMode.OpenFolder: return(FileSystemElement.Folder); default: return(FileSystemElement.File); } }
/// <inheritdoc/> bool IDialogHandler.OnFileDialog( IWebBrowser chromiumWebBrowser, IBrowser browser, CefFileDialogMode mode, CefFileDialogFlags flags, string title, string defaultFilePath, List <string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback) { return(OnFileDialog(chromiumWebBrowser, browser, mode, flags, title, defaultFilePath, acceptFilters, selectedAcceptFilter, callback)); }
/// <summary> /// Call to run a file chooser dialog. Only a single file chooser dialog may be /// pending at any given time. |mode| represents the type of dialog to display. /// |title| to the title to be used for the dialog and may be empty to show the /// default title ("Open" or "Save" depending on the mode). |default_file_name| /// is the default file name to select in the dialog. |accept_types| is a list /// of valid lower-cased MIME types or file extensions specified in an input /// element and is used to restrict selectable files to such types. |callback| /// will be executed after the dialog is dismissed or immediately if another /// dialog is already pending. The dialog will be initiated asynchronously on /// the UI thread. /// </summary> public void RunFileDialog(CefFileDialogMode mode, string title, string defaultFileName, string[] acceptTypes, CefRunFileDialogCallback callback) { fixed(char *title_ptr = title) fixed(char *defaultFileName_ptr = defaultFileName) { var n_title = new cef_string_t(title_ptr, title != null ? title.Length : 0); var n_defaultFileName = new cef_string_t(defaultFileName_ptr, defaultFileName != null ? defaultFileName.Length : 0); var n_acceptTypes = cef_string_list.From(acceptTypes); cef_browser_host_t.run_file_dialog(_self, mode, &n_title, &n_defaultFileName, n_acceptTypes, callback.ToNative()); libcef.string_list_free(n_acceptTypes); } }
private int on_file_dialog(cef_dialog_handler_t* self, cef_browser_t* browser, CefFileDialogMode mode, cef_string_t* title, cef_string_t* default_file_name, cef_string_list* accept_types, cef_file_dialog_callback_t* callback) { CheckSelf(self); var mBrowser = CefBrowser.FromNative(browser); var mTitle = cef_string_t.ToString(title); var mDefaultFileName = cef_string_t.ToString(default_file_name); var mAcceptTypes = cef_string_list.ToArray(accept_types); var mCallback = CefFileDialogCallback.FromNative(callback); var result = OnFileDialog(mBrowser, mode, mTitle, mDefaultFileName, mAcceptTypes, mCallback); return result ? 1 : 0; }
public bool OnFileDialog(IWebBrowser browserControl, IBrowser browser, CefFileDialogMode mode, string title, string defaultFilePath, List <string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback) { if (_cancelDialog) { callback.Cancel(); } else { callback.Continue(selectedAcceptFilter, _filePaths); } return(true); }
/// <summary> /// Call to run a file chooser dialog. Only a single file chooser dialog may be /// pending at any given time. |mode| represents the type of dialog to display. /// |title| to the title to be used for the dialog and may be NULL to show the /// default title ("Open" or "Save" depending on the mode). |default_file_path| /// is the path with optional directory and/or file name component that will be /// initially selected in the dialog. |accept_filters| are used to restrict the /// selectable file types and may any combination of (a) valid lower-cased MIME /// types (e.g. "text/*" or "image/*"), (b) individual file extensions (e.g. /// ".txt" or ".png"), or (c) combined description and file extension delimited /// using "|" and ";" (e.g. "Image Types|.png;.gif;.jpg"). /// |selected_accept_filter| is the 0-based index of the filter that will be /// selected by default. |callback| will be executed after the dialog is /// dismissed or immediately if another dialog is already pending. The dialog /// will be initiated asynchronously on the UI thread. /// </summary> public unsafe virtual void RunFileDialog(CefFileDialogMode mode, string title, string defaultFilePath, CefStringList acceptFilters, bool selectedAcceptFilter, CefRunFileDialogCallback callback) { fixed(char *s1 = title) fixed(char *s2 = defaultFilePath) { var cstr1 = new cef_string_t { Str = s1, Length = title != null ? title.Length : 0 }; var cstr2 = new cef_string_t { Str = s2, Length = defaultFilePath != null ? defaultFilePath.Length : 0 }; NativeInstance->RunFileDialog(mode, &cstr1, &cstr2, acceptFilters.GetNativeInstance(), selectedAcceptFilter ? 1 : 0, (callback != null) ? callback.GetNativeInstance() : null); } GC.KeepAlive(this); }
public bool OnFileDialog(IWebBrowser browserControl, IBrowser browser, CefFileDialogMode mode, string title, string defaultFilePath, List <string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback) { if (!string.IsNullOrEmpty(TweetDeckBridge.ClipboardImagePath)) { callback.Continue(selectedAcceptFilter, new List <string> { TweetDeckBridge.ClipboardImagePath }); form.InvokeSafe(() => { TweetDeckBridge.ClipboardImagePath = string.Empty; }); return(true); } return(false); }
/// <summary> /// Call to run a file chooser dialog. Only a single file chooser dialog may be /// pending at any given time. |mode| represents the type of dialog to display. /// |title| to the title to be used for the dialog and may be empty to show the /// default title ("Open" or "Save" depending on the mode). |default_file_path| /// is the path with optional directory and/or file name component that will be /// initially selected in the dialog. |accept_filters| are used to restrict the /// selectable file types and may any combination of (a) valid lower-cased MIME /// types (e.g. "text/*" or "image/*"), (b) individual file extensions (e.g. /// ".txt" or ".png"), or (c) combined description and file extension delimited /// using "|" and ";" (e.g. "Image Types|.png;.gif;.jpg"). /// |selected_accept_filter| is the 0-based index of the filter that will be /// selected by default. |callback| will be executed after the dialog is /// dismissed or immediately if another dialog is already pending. The dialog /// will be initiated asynchronously on the UI thread. /// </summary> public void RunFileDialog(CefFileDialogMode mode, string title, string defaultFilePath, string[] acceptFilters, int selectedAcceptFilter, CefRunFileDialogCallback callback) { if (callback == null) { throw new ArgumentNullException("callback"); fixed(char *title_ptr = title) fixed(char *defaultFilePath_ptr = defaultFilePath) { var n_title = new cef_string_t(title_ptr, title != null ? title.Length : 0); var n_defaultFilePath = new cef_string_t(defaultFilePath_ptr, defaultFilePath != null ? defaultFilePath.Length : 0); var n_acceptFilters = cef_string_list.From(acceptFilters); cef_browser_host_t.run_file_dialog(_self, mode, &n_title, &n_defaultFilePath, n_acceptFilters, selectedAcceptFilter, callback.ToNative()); libcef.string_list_free(n_acceptFilters); } }
public static void run_file_dialog(cef_browser_host_t *self, CefFileDialogMode mode, cef_string_t *title, cef_string_t *default_file_name, cef_string_list *accept_types, cef_run_file_dialog_callback_t *callback) { run_file_dialog_delegate d; var p = self->_run_file_dialog; if (p == _pd) { d = _dd; } else { d = (run_file_dialog_delegate)Marshal.GetDelegateForFunctionPointer(p, typeof(run_file_dialog_delegate)); if (_pd == IntPtr.Zero) { _dd = d; _pd = p; } } d(self, mode, title, default_file_name, accept_types, callback); }
private DialogRequestedEventArgs RequestDialog(CefFileDialogMode mode, bool confirm = true) { var args = default(DialogRequestedEventArgs); var callback = new Mock <IFileDialogCallback>(); var title = "Some random dialog title"; var initialPath = @"C:\Some\Random\Path"; var sync = new AutoResetEvent(false); var threadId = default(int); callback.Setup(c => c.Cancel()).Callback(() => sync.Set()); callback.Setup(c => c.Continue(It.IsAny <int>(), It.IsAny <List <string> >())).Callback(() => sync.Set()); sut.DialogRequested += (a) => { args = a; args.Success = confirm; args.FullPath = @"D:\Some\Other\File\Path.txt"; threadId = Thread.CurrentThread.ManagedThreadId; }; var status = sut.OnFileDialog(default(IWebBrowser), default(IBrowser), mode, default(CefFileDialogFlags), title, initialPath, default(List <string>), default(int), callback.Object); sync.WaitOne(); if (confirm) { callback.Verify(c => c.Continue(It.IsAny <int>(), It.IsAny <List <string> >()), Times.Once); callback.Verify(c => c.Cancel(), Times.Never); } else { callback.Verify(c => c.Continue(It.IsAny <int>(), It.IsAny <List <string> >()), Times.Never); callback.Verify(c => c.Cancel(), Times.Once); } Assert.IsTrue(status); Assert.AreEqual(initialPath, args.InitialPath); Assert.AreEqual(title, args.Title); Assert.AreNotEqual(threadId, Thread.CurrentThread.ManagedThreadId); return(args); }
public bool OnFileDialog(IWebBrowser browserControl, IBrowser browser, CefFileDialogMode mode, string title, string defaultFilePath, List <string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback) { CefFileDialogMode dialogType = mode & CefFileDialogMode.TypeMask; if (dialogType == CefFileDialogMode.Open || dialogType == CefFileDialogMode.OpenMultiple) { string allFilters = string.Join(";", acceptFilters.Select(filter => "*" + filter)); using (OpenFileDialog dialog = new OpenFileDialog { AutoUpgradeEnabled = true, DereferenceLinks = true, Multiselect = dialogType == CefFileDialogMode.OpenMultiple, Title = "Open Files", Filter = $"All Supported Formats ({allFilters})|{allFilters}|All Files (*.*)|*.*" }){ if (dialog.ShowDialog() == DialogResult.OK) { string ext = Path.GetExtension(dialog.FileName); callback.Continue(acceptFilters.FindIndex(filter => filter.Equals(ext, StringComparison.OrdinalIgnoreCase)), dialog.FileNames.ToList()); } else { callback.Cancel(); } callback.Dispose(); } return(true); } else { callback.Dispose(); return(false); } }
/// <summary> /// Called to run a file chooser dialog. |mode| represents the type of dialog /// to display. |title| to the title to be used for the dialog and may be empty /// to show the default title ("Open" or "Save" depending on the mode). /// |default_file_name| is the default file name to select in the dialog. /// |accept_types| is a list of valid lower-cased MIME types or file extensions /// specified in an input element and is used to restrict selectable files to /// such types. To display a custom dialog return true and execute |callback| /// either inline or at a later time. To display the default dialog return /// false. /// </summary> protected virtual bool OnFileDialog(CefBrowser browser, CefFileDialogMode mode, string title, string defaultFileName, string[] acceptTypes, CefFileDialogCallback callback) { return false; }
public bool OnFileDialog(IWebBrowser browser, CefFileDialogMode mode, string title, string defaultFileName, List<string> acceptTypes, out List<string> result) { result = new List<string> { Path.GetRandomFileName() }; return true; }
/// <summary> /// Call to run a file chooser dialog. Only a single file chooser dialog may be /// pending at any given time. |mode| represents the type of dialog to display. /// |title| to the title to be used for the dialog and may be empty to show the /// default title ("Open" or "Save" depending on the mode). |default_file_name| /// is the default file name to select in the dialog. |accept_types| is a list /// of valid lower-cased MIME types or file extensions specified in an input /// element and is used to restrict selectable files to such types. |callback| /// will be executed after the dialog is dismissed or immediately if another /// dialog is already pending. The dialog will be initiated asynchronously on /// the UI thread. /// </summary> public void RunFileDialog(CefFileDialogMode mode, string title, string defaultFileName, string[] acceptTypes, CefRunFileDialogCallback callback) { fixed (char* title_ptr = title) fixed (char* defaultFileName_ptr = defaultFileName) { var n_title = new cef_string_t(title_ptr, title != null ? title.Length : 0); var n_defaultFileName = new cef_string_t(defaultFileName_ptr, defaultFileName != null ? defaultFileName.Length : 0); var n_acceptTypes = cef_string_list.From(acceptTypes); cef_browser_host_t.run_file_dialog(_self, mode, &n_title, &n_defaultFileName, n_acceptTypes, callback.ToNative()); libcef.string_list_free(n_acceptTypes); } }
public static void run_file_dialog(cef_browser_host_t* self, CefFileDialogMode mode, cef_string_t* title, cef_string_t* default_file_name, cef_string_list* accept_types, cef_run_file_dialog_callback_t* callback) { run_file_dialog_delegate d; var p = self->_run_file_dialog; if (p == _pd) { d = _dd; } else { d = (run_file_dialog_delegate)Marshal.GetDelegateForFunctionPointer(p, typeof(run_file_dialog_delegate)); if (_pd == IntPtr.Zero) { _dd = d; _pd = p; } } d(self, mode, title, default_file_name, accept_types, callback); }
private int on_file_dialog(cef_dialog_handler_t *self, cef_browser_t *browser, CefFileDialogMode mode, cef_string_t *title, cef_string_t *default_file_name, cef_string_list *accept_types, cef_file_dialog_callback_t *callback) { CheckSelf(self); var mBrowser = CefBrowser.FromNative(browser); var mTitle = cef_string_t.ToString(title); var mDefaultFileName = cef_string_t.ToString(default_file_name); var mAcceptTypes = cef_string_list.ToArray(accept_types); var mCallback = CefFileDialogCallback.FromNative(callback); var result = OnFileDialog(mBrowser, mode, mTitle, mDefaultFileName, mAcceptTypes, mCallback); return(result ? 1 : 0); }
protected override bool OnFileDialog(CefBrowser browser, CefFileDialogMode mode, string title, string defaultFilePath, string[] acceptFilters, int selectedAcceptFilter, CefFileDialogCallback callback) { return(base.OnFileDialog(browser, mode, title, defaultFilePath, acceptFilters, selectedAcceptFilter, callback)); }
/// <summary> /// Call to run a file chooser dialog. Only a single file chooser dialog may be /// pending at any given time. |mode| represents the type of dialog to display. /// |title| to the title to be used for the dialog and may be empty to show the /// default title ("Open" or "Save" depending on the mode). |default_file_path| /// is the path with optional directory and/or file name component that will be /// initially selected in the dialog. |accept_filters| are used to restrict the /// selectable file types and may any combination of (a) valid lower-cased MIME /// types (e.g. "text/*" or "image/*"), (b) individual file extensions (e.g. /// ".txt" or ".png"), or (c) combined description and file extension delimited /// using "|" and ";" (e.g. "Image Types|.png;.gif;.jpg"). /// |selected_accept_filter| is the 0-based index of the filter that will be /// selected by default. |callback| will be executed after the dialog is /// dismissed or immediately if another dialog is already pending. The dialog /// will be initiated asynchronously on the UI thread. /// </summary> public void RunFileDialog(CefFileDialogMode mode, string title, string defaultFilePath, string[] acceptFilters, int selectedAcceptFilter, CefRunFileDialogCallback callback) { BrowserHost?.RunFileDialog(mode, title, defaultFilePath, acceptFilters, selectedAcceptFilter, callback); }
public bool OnFileDialog(IWebBrowser browserControl, IBrowser browser, CefFileDialogMode mode, string title, string defaultFilePath, List<string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback) { callback.Continue(selectedAcceptFilter, new List<string> { Path.GetRandomFileName() }); return true; }
/// <summary> /// Called to run a file chooser dialog. |mode| represents the type of dialog /// to display. |title| to the title to be used for the dialog and may be empty /// to show the default title ("Open" or "Save" depending on the mode). /// |default_file_name| is the default file name to select in the dialog. /// |accept_types| is a list of valid lower-cased MIME types or file extensions /// specified in an input element and is used to restrict selectable files to /// such types. To display a custom dialog return true and execute |callback| /// either inline or at a later time. To display the default dialog return /// false. /// </summary> protected virtual bool OnFileDialog(CefBrowser browser, CefFileDialogMode mode, string title, string defaultFileName, string[] acceptTypes, CefFileDialogCallback callback) { return(false); }
/// <inheritdoc /> internal protected override bool OnFileDialog(CefBrowser browser, CefFileDialogMode mode, string title, string defaultFilePath, CefStringList acceptFilters, int selectedAcceptFilter, CefFileDialogCallback callback) { callback.Cancel(); return(true); }
public bool OnFileDialog(IWebBrowser browserControl, IBrowser browser, CefFileDialogMode mode, string title, string defaultFilePath, List <string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback) { MessageBox.Show(defaultFilePath, title); return(true); }
public bool OnFileDialog(IWebBrowser chromiumWebBrowser, IBrowser browser, CefFileDialogMode mode, CefFileDialogFlags flags, string title, string defaultFilePath, List <string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback) { try { var files = new List <FsFile>(); if (CefFileDialogMode.OpenFolder == (mode & CefFileDialogMode.OpenFolder)) { using (var dialog = new FolderBrowserDialog() { SelectedPath = defaultFilePath.DefaultIfNullOrWhiteSpace(_app.LastFileDialogDirectory) }) { if (!string.IsNullOrWhiteSpace(title)) { dialog.Description = title; } if (dialog.ShowDialog() == DialogResult.OK) { var dir = new DirectoryInfo(dialog.SelectedPath); _app.LastFileDialogDirectory = dir.FullName; files.Add(new FsFile() { Name = dir.Name, Path = dir.FullName, Type = "directory", LastModified = (long)Utils.ConvertToUnixTimestamp(dir.LastWriteTime) }); OsEvent.Emit(replyMsgName, null, false, files); callback.Continue(selectedAcceptFilter, new List <string> { dialog.SelectedPath }); } else { OsEvent.Emit(replyMsgName, null, true, files); callback.Cancel(); } } } else { var filter = string.Join("|", acceptFilters.Select(ext => { if (string.IsNullOrWhiteSpace(ext)) { return(""); } var fileType = Utils.GetFileType(ext); if (string.IsNullOrWhiteSpace(fileType)) { // Maybe the accept type is already a mime type fileType = ext; ext = Utils.GetFileTypeExtension(fileType); if (string.IsNullOrWhiteSpace(ext)) { return(""); } } return($"{fileType}|*{ext}"); })); if (string.IsNullOrWhiteSpace(filter)) { filter = "All Files|*.*"; } using (var dialog = new OpenFileDialog { Multiselect = CefFileDialogMode.OpenMultiple == (mode & CefFileDialogMode.OpenMultiple), Title = title, Filter = filter, InitialDirectory = defaultFilePath.DefaultIfNullOrWhiteSpace(_app.LastFileDialogDirectory), FilterIndex = selectedAcceptFilter }) { if (dialog.ShowDialog() == DialogResult.OK) { if (dialog.FileNames != null) { files = dialog.FileNames.Select(f => { var file = new FileInfo(f); return(new FsFile() { Name = file.Name, Path = file.FullName, Size = file.Length, Type = Utils.GetMimeType(file.Extension), LastModified = (long)Utils.ConvertToUnixTimestamp(file.LastWriteTime) }); }).ToList(); if (files.Count > 0) { _app.LastFileDialogDirectory = Path.GetDirectoryName(files.Last().Path); } } OsEvent.Emit(replyMsgName, null, false, files); callback.Continue(selectedAcceptFilter, dialog.FileNames.ToList()); } else { OsEvent.Emit(replyMsgName, null, true, files); callback.Cancel(); } } } } catch (Exception e) { OsEvent.Emit(replyMsgName, e); } return(true); }