CopyFile (copy a file)
ts
function CopyFile(what: string, toWhere: string): boolean;Copies the file specified by what to the toWhere destination directory in the local file system. Returns true if the copy is successful, or false if it fails.
| Parameter | Type | Requirement | Explanation |
|---|---|---|---|
what | string | required | Path to a valid, existing file in the local file system |
toWhere | string | required | Path to a valid, existing directory in the local file system where the file will be copied |
| Return value | Explanation |
|---|---|
true | The file was successfully copied to the destination folder |
false | The copy operation failed; the file was not copied |
NOTE
This function does not overwrite existing files in the destination directory. If a file with the same name already exists in toWhere, the operation will fail and return false.
Example
ts
var result = CopyFile('/home/user/data.txt', '/home/user/backup');
if (result) {
Log('File copied successfully.');
} else {
Log('File copy failed.');
}