Syntax
openfilesdialog(options?: DialogOptions): { FileSystemItem } | nilArguments
| Name | Type | Description |
|---|---|---|
options? | DialogOptions | Optional table. For openfilesdialog, title, defaultPath, and extensionFilter are used. extensionFilter is a table of extension strings; leading . or *. is stripped before each filter becomes *.<extension>. |
Returns
| Name | Type | Description |
|---|---|---|
files | { FileSystemItem } | nil | Array table of selected file items, or nil when the dialog is cancelled or no selected filesystem paths are returned. Dialog failures throw Failed to open file dialog. |
Description
Opens a Windows file-open dialog with Windows file picker with multi-select enabled and returns the selected files as file item values.
Call it with 1 parameter(s): options. The argument table explains which values are required and which ones only refine the behavior.
It returns files ({ FileSystemItem } | nil). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Let the user select one or more files and handle each selected file item.
local files = openfilesdialog({
title = "Choose source files",
defaultPath = ".",
extensionFilter = { "lua", "luau", "txt" },
})
if files then
for _, file in ipairs(files) do
print(file:GetName())
print(file:IsFile())
end
else
print("No files selected")
endTypes
DialogOptions
Configures the Windows 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.