fileCreate
Creates a new file in a directory of a resource. If there already exists a file with the specified name, it is overwritten with an empty file.
To prevent memory leaks, ensure each successful call to fileCreate has a matching call to fileClose.
If you do not want to share the content of the created file with other servers, prepend the file path with @ (See Filepath for more information).
It is important to remember to close a file after you've finished all your operations on it, especially if you've been writing to the file. If you don't close a file and your resource crashes, all changes to the file may be lost.
OOP Syntax Help! I don't understand this!
- Method: File.new(...)
Syntax
bool fileCreate ( string filePath )
Required Arguments
- filePath: The path of the file you want to copy.
Returns
- bool: result
If successful, returns a file handle which can be used with other file functions (fileWrite, fileClose etc.). Returns false if an error occured.
Code Examples
This example creates a text file in the current resource and writes a string to it.
local newFile = fileCreate("test.txt") -- attempt to create a new fileif (newFile) then -- check if the creation succeeded fileWrite(newFile, "This is a test file!") -- write a text line fileClose(newFile) -- close the file once you're done with itend