Document: Read Synchronous
Read all bytes from a file chosen through a system dialog. Decode the resulting string yourself if the file contains JSON or another structured format.
Luau
Document:Read() -> stringParameters
Call this method with a Document receiver. The colon supplies self implicitly; a dot call must pass the receiver explicitly.
This function takes no arguments.
Returns
stringThe file contents as a string.
Usage notes
A Document is a handle to the user-selected location, not a workspace path. Call methods with a colon and keep the handle for later operations.
Calling Read on a folder raises.
Example
Luau
local document = openfiledialog({ extensionFilter = { "txt" } })
if document then
local text = document:Read()
print("First 80 characters:", string.sub(text, 1, 80))
end