ui.showOpenFileDialog
Description
Shows an open file dialog.

Parameters
caption string (window title)
initialFilename string (initial filename or folder to display)
filter string (file extensions to include see example 1)
defaultExt string (default extension to append if none is provided by the user)

Return value
selectedFilename string (or empty string if cancelled)

Example
-- example 1
local filename = ui.showOpenFileDialog("Select Text File", "", "Text Files|*.txt|All Files|*.*", "txt")
if filename ~= "" then
    print("Selected file " .. filename)
else
    print("No file was picked")
end

-- example 2
local filename = ui.showOpenFileDialog("Select Any File", "C:\\Some Folder\\", "", "")

-- example 3
local filename = ui.showOpenFileDialog("Select Any File", "C:\\Some Folder\\Some File.txt", "", "")

Comments
The initialFilename parameter defaults to My Documents folder if empty string is provided.

See also
ui.showSaveFileDialog
io.getSpecialFolderPath

Back
Generated on the 26 June 2024 at 22:01:29 (UK Time)