Warning
- This operation will block program flow execution.
- Use File.copytask() to copy the file asynchronously.
File:copy(filename) method
Copies the file physically on the disk to the specified filename.
Parameters
filename
A string representing the destination filename.
If the filename contains a path, the path must already exist. If the destination file exists, the function will fail.
Return value
Returns aboolean
value indicating if the operation succeeded.
Example
local file = sys.File("test.txt"):open("write")
file:writeln("Hello World !")
file:close()
-- outputs false : cannot copy "test.txt" to "test.txt"
print(file:copy("test.txt"))