Syntax
openfolderdialog(options?: DialogOptions): FileSystemItem | nilArguments
| Name | Type | Description |
|---|---|---|
options? | DialogOptions | Optional settings table that controls how the operation behaves. |
Returns
| Name | Type | Description |
|---|---|---|
folder | FileSystemItem | nil | Selected folder metadata, or nil when cancelled. |
Description
Opens a native folder picker and returns the selected folder metadata.
Call it with 1 parameter(s): options. The argument table explains which values are required and which ones only refine the behavior.
It returns folder (FileSystemItem | nil). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Let the user select a folder from a native dialog.
local folder = openfolderdialog({
title = "Choose a workspace folder",
defaultPath = "workspace",
})
if folder then
print(folder)
endTypes
DialogOptions
Configures the native file or folder selection dialog.
title? string Sets the dialog window title.defaultPath? string Selects the directory shown when the dialog opens.extensionFilter? {string} Limits selectable files to the listed extensions, with or without a leading dot.suggestedName? string Provides the initial file name in save dialogs.defaultExtension? string Sets the extension used when the entered file name has none.