getfilesize Synchronous

Read a workspace file's size without loading its contents. Check it before reading a file that might be too large to handle comfortably.

Syntax
Luau
getfilesize(path: string) -> number

Parameters

Function parameters
ParameterTypeDescription
pathstringWorkspace-relative path of the file.

Returns

number

The size in bytes.

Usage notes

The call raises if the path is not an existing file. Folders have no size here.

Example

Example
Luau
writefile("size-example.txt", "12345")
print(getfilesize("size-example.txt")) -- 5
delfile("size-example.txt")