fileCopy
Client-side
Server-side
Shared
This function copies a file.
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).
OOP Syntax Help! I don't understand this!
- Method: File.copy(...)
Syntax
bool fileCopy ( string filePath, string copyToFilePath, [ bool overwrite = false ] )
Required Arguments
- filePath: The path of the file you want to copy.
- copyToFilePath: Where to copy the specified file to.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.
- overwrite (default: false): If set to true it will overwrite a file that already exists at
copyToFilePath
.
Returns
- bool: result
Return true if the file was copied, else false if the filePath
doesn't exist.
Code Examples
client
This example copies a file called test.txt
and called it test1.txt
.
addEventHandler("onClientResourceStart", resourceRoot, function(res) local filePath = ":"..getResourceName(res).."/test.txt" fileCreate(filePath) --create the file in this resource and name it 'test.txt'. if fileCopy(filePath,":"..getResourceName(res).."/test1.txt") then outputChatBox("File was successfully copied!", 0, 100, 0) else outputChatBox("File was not successfully copied, probably because it doesn't exist.", 100, 0, 0) endend)