OpenFileDialog

Pops up a dialog box for the user to open a file.

Constructors

this
this(Window parent, string title)

Construct the dialog.

this
this(string title)

Construct the dialog.

Members

Functions

getResults
string[] getResults()

Get multiple dialog results.

setMultiSelection
auto setMultiSelection(bool enable)

Set whether to enable mutli-selection.

show
auto show()

Show the dialog.

Variables

_selectMultiple
bool _selectMultiple;
Undocumented in source.

Inherited Members

From FileDialog

_defaultExtension
string _defaultExtension;
Undocumented in source.
_fileTypes
string[] _fileTypes;
Undocumented in source.
_initialDirectory
string _initialDirectory;
Undocumented in source.
_initialFile
string _initialFile;
Undocumented in source.
_typeVariable
string _typeVariable;
Undocumented in source.
setDefaultExtension
auto setDefaultExtension(string extension)

Set the default extension.

addFileType
auto addFileType(string fileType)

Add an allowed file type. If a filetype combobox exists in the file dialog on the particular platform, this adds entries to it. When the user choose a filetype in the combobox, only the files of that type are listed. If no types are added or if the filetypes combobox is not supported by the particular platform then all files are listed regardless of their types.

setInitialDirectory
auto setInitialDirectory(string directory)

Set the initial directory in the dialog.

setInitialFile
auto setInitialFile(string file)

Set the initial file in the dialog.

Examples

auto dialog = new OpenFileDialog("Open a file")
	.setMultiSelection(false)
	.setDefaultExtension(".txt")
	.addFileType("{{All files} {*}}")
	.addFileType("{{Text files} {.txt}}")
	.setInitialDirectory("~")
	.setInitialFile("file.txt")
	.show();

string fileToOpen = dialog.getResult();

Result: The full path of the file selected.

See Also

Meta