FileDialogItem
File and folder handles returned by workspace pickers.
Wrapper returned by openfiledialog, openfilesdialog, openfolderdialog, and savefiledialog. The wrapper captures its workspace-relative path at creation time; file-only methods are attached on items that pointed to a file at creation, and folder-only methods on items that pointed to a folder.
Shared members
| Member | Type / signature | Meaning |
|---|---|---|
Path | string | Workspace-relative path captured by the item. |
GetName | GetName(): string | Returns the last path component. |
IsFile | IsFile(): boolean | Rechecks whether the captured path currently refers to a file. |
IsFolder | IsFolder(): boolean | Rechecks whether the captured path currently refers to a folder. |
Delete | Delete(): () | Deletes the captured path; folders are removed recursively. |
File methods
Present when the item was created from a file path.
| Member | Type / signature | Meaning |
|---|---|---|
Read | Read(): string | Reads the file's full contents. |
Write | Write(contents: string): () | Overwrites the file with contents. |
Append | Append(contents: string): () | Appends contents to the end of the file. |
Folder methods
Present when the item was created from a folder path.
| Member | Type / signature | Meaning |
|---|---|---|
List | List(recursive: boolean?): {FileDialogItem} | Lists immediate children; set recursive = true to descend through subfolders. |
MakeFolder | MakeFolder(name: string): FileDialogItem | Creates a child directory and returns its wrapper. |
Notes
- Changing the exposed
Pathfield does not change the captured path used by the item's methods — reassigningPathis cosmetic. - The path type (file vs. folder) is resolved once at creation. Recheck with
IsFile/IsFolderif another script can move or replace the path.
Example
local selected = openfiledialog({ extensionFilter = { "txt" } })
if selected and selected:IsFile() then
print(selected:GetName(), #selected:Read())
end