FileCopy

Description

Copies one file to another, optionally overwriting the target file.

Syntax

FileCopy ( sourcefile, targetfile {, replace } )

Argument

Description

sourcefile

String for the name of the file you want to copy

targetfile

String for the name of the file you are copying to

replace(optional)

Boolean specifying whether to replace the target file (true) or not (false)


Return value

Integer.

Returns values as follows:

1 -- Success

-1 -- Error opening sourcefile

-2 -- Error writing targetfile

Usage

If you do not specify a fully qualified path for sourcefile or for targetfile, the function works relative to the current directory. If you do not specify the replace argument, the FileCopy function does not replace a file in the target directory that has the same name as the name you specify in the targetfile argument (This is equivalent to setting the replace value to false).

Examples

The following example copies a file from the current directory to a different directory and saves the return value in a variable. It does not replace a file of the same name if one already exists in the target directory:

integer li_FileNum
li_FileNum = FileCopy ("jazz.gif" , &
   "C:\emusic\jazz.gif", FALSE)

See also

FileMove

GetCurrentDirectory