- Documentation
- Shared functions
- fileExists
Function
fileExists
Checks whether a file with this path exists.
Syntax
bool fileExists(string filePath)Arguments
filePathstring- File path.
Returns
true when it exists.
Example
local file = fileExists("data.json") and fileOpen("data.json") or fileCreate("data.json")
fileClose(file)
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.fileCreateCreates 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).