Table of Contents

Class FileDialog

Namespace
Godot
Assembly
GodotSharp.dll

FileDialog is a preset dialog used to choose files and directories in the filesystem. It supports filter masks. FileDialog automatically sets its window title according to the FileMode. If you want to use a custom title, disable this by setting ModeOverridesTitle to false.

public class FileDialog : ConfirmationDialog, IDisposable
Inheritance
FileDialog
Implements
Inherited Members

Constructors

FileDialog()

public FileDialog()

Properties

Access

The file system access scope. See FileDialog.AccessEnum constants.

Warning: Currently, in sandboxed environments such as Web builds or sandboxed macOS apps, FileDialog cannot access the host file system. See godot-proposals#1123.

public FileDialog.AccessEnum Access { get; set; }

Property Value

FileDialog.AccessEnum

CurrentDir

The current working directory of the file dialog.

public string CurrentDir { get; set; }

Property Value

string

CurrentFile

The currently selected file of the file dialog.

public string CurrentFile { get; set; }

Property Value

string

CurrentPath

The currently selected file path of the file dialog.

public string CurrentPath { get; set; }

Property Value

string

FileMode

The dialog's open or save mode, which affects the selection behavior. See FileDialog.FileModeEnum.

public FileDialog.FileModeEnum FileMode { get; set; }

Property Value

FileDialog.FileModeEnum

Filters

The available file type filters. For example, this shows only .png and .gd files: set_filters(PackedStringArray(["*.png ; PNG Images","*.gd ; GDScript Files"])). Multiple file types can also be specified in a single filter. "*.png, *.jpg, *.jpeg ; Supported Images" will show both PNG and JPEG files when selected.

public string[] Filters { get; set; }

Property Value

string[]

ModeOverridesTitle

If true, changing the FileMode property will set the window title accordingly (e.g. setting FileMode to OpenFile will change the window title to "Open a File").

public bool ModeOverridesTitle { get; set; }

Property Value

bool

RootSubfolder

If non-empty, the given sub-folder will be "root" of this FileDialog, i.e. user won't be able to go to its parent directory.

public string RootSubfolder { get; set; }

Property Value

string

ShowHiddenFiles

If true, the dialog will show hidden files.

public bool ShowHiddenFiles { get; set; }

Property Value

bool

UseNativeDialog

If true, Access is set to Filesystem, and it is supported by the current DisplayServer, OS native dialog will be used instead of custom one.

Note: On macOS, sandboxed apps always use native dialogs to access host filesystem.

public bool UseNativeDialog { get; set; }

Property Value

bool

Methods

AddFilter(string, string)

Adds a comma-delimited file name filter option to the FileDialog with an optional description, which restricts what files can be picked.

A filter should be of the form "filename.extension", where filename and extension can be * to match any string. Filters starting with . (i.e. empty filenames) are not allowed.

For example, a filter of "*.png, *.jpg" and a description of "Images" results in filter text "Images (*.png, *.jpg)".

public void AddFilter(string filter, string description = "")

Parameters

filter string
description string

ClearFilters()

Clear all the added filters in the dialog.

public void ClearFilters()

DeselectAll()

Clear all currently selected items in the dialog.

public void DeselectAll()

GetLineEdit()

Returns the LineEdit for the selected file.

Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their Visible property.

public LineEdit GetLineEdit()

Returns

LineEdit

GetVBox()

Returns the vertical box container of the dialog, custom controls can be added to it.

Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their Visible property.

public VBoxContainer GetVBox()

Returns

VBoxContainer

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

Invalidate()

Invalidate and update the current dialog content list.

public void Invalidate()

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

Events

DirSelected

Emitted when the user selects a directory.

public event FileDialog.DirSelectedEventHandler DirSelected

Event Type

FileDialog.DirSelectedEventHandler

FileSelected

Emitted when the user selects a file by double-clicking it or pressing the OK button.

public event FileDialog.FileSelectedEventHandler FileSelected

Event Type

FileDialog.FileSelectedEventHandler

FilesSelected

Emitted when the user selects multiple files.

public event FileDialog.FilesSelectedEventHandler FilesSelected

Event Type

FileDialog.FilesSelectedEventHandler