Show / Hide Table of Contents

Class FileOpenSaveDialog

Shows standard "Open", "Save As" or "Select Folder" dialog to select a file or folder.

public class FileOpenSaveDialog
Remarks

This class exists because the similar .NET classes have these problems:

  • May disable the System.AppDomain.UnhandledException event.
  • As owner window they support only Window or Form. This class also supports window handles.
  • They support only filesystem items.
  • There is no option to not add the selected file to recent files that are displayed in the context menu of the taskbar button etc.
  • The WPF class does not have a ClientGuid property.

There are 2 main dialog types - open (FileOpenSaveDialog.ShowOpen) and save (FileOpenSaveDialog.ShowSave). All other functions of this class (properties, etc) are common to opening and saving.

Examples
var d = new FileOpenSaveDialog { FileTypes = "Text files|*.txt|All files|*.*" };
if(d.ShowOpen(out string s)) print.it(s);

Namespace: Au.More
Assembly: Au.dll
Inheritance
object
FileOpenSaveDialog

Constructors

Name Description
FileOpenSaveDialog(string, bool)

Properties

Name Description
CommonFlags

Options common to all dialog types. Rarely used.

DefaultExt

Default extension to add to file names. Must be like "txt", not like ".txt". If null (default), gets from FileOpenSaveDialog.FileTypes; set "" to prevent it.

FileNameLabel

Sets the file name edit box label.

FileNameText

Sets the initial file name text in the edit box.

FileTypeIndex

1-based index of the selected file type (see FileOpenSaveDialog.FileTypes).

FileTypes

List of file types, like with Microsoft.Win32.FileDialog.Filter. Example: "Text files|*.txt|Office files|*.doc;*.xls|All files|*.*"

InitFolderFirstTime

Initial folder for the first time. Later is used the recently used folder instead.

InitFolderNow

Initial folder to use now. In most cases it's recommended to use FileOpenSaveDialog.InitFolderFirstTime instead.

OkButtonLabel

Sets the OK button label.

Title

Sets the dialog window name.

Methods

Name Description
ShowOpen(out string, AnyWnd, bool, bool, bool, bool)

Shows "Open" or "Select Folder" dialog that allows to select single item.

ShowOpen(out string[], AnyWnd, bool, bool, bool, bool)

Shows "Open" or "Select Folder" dialog that allows to select multiple items.

ShowSave(out string, AnyWnd, bool, string)

Shows "Save As" dialog.