Skip to content
File systemReference

readfile

Read all bytes from a workspace file.

Details#

Read all bytes from a workspace file. Binary file contents, including embedded NUL bytes. Missing files, folders and read failures cause an error.

Signature#

Luau
readfile(path: string): string

Parameters#

ParameterTypeDescription
pathstringUTF-8 path relative to the application's workspace.

Returns#

Binary file contents, including embedded NUL bytes. Missing files, folders and read failures cause an error.

Examples#

Local example

Luau
writefile("docs-example/note.txt", "Hello")
print(readfile("docs-example/note.txt")) -- Hello