- Documentation
- Shared functions
- fileCreate
Function
fileCreate
Creates a new file or empties an existing one and opens it for writing. On the client the files go to a private folder for that server on the player's computer (limit 64 MB per file and 256 MB per server).
Syntax
file fileCreate(string filePath)Arguments
filePathstring- File path.
Returns
A file handle, or false.
Example
local file = fileCreate("settings.json")
if file then
fileWrite(file, toJSON({ volume = 0.5, hud = true }))
fileClose(file)
end
See also
fileOpenOpens an existing file for reading and writing (or read-only). On the server the path is relative to the resource folder and cannot leave it. On the client it first looks for the script's own files (written withfileCreate), then for<file>files sent by the server - those are read-only;":other/file"points to another resource's file. Close the file withfileClosewhen done.fileWriteWrites strings from the current position (each argument one after another) and moves the position. Supports binary data.fileCloseCloses a file and writes its buffer to disk. The handle becomes invalid.