CopyFile

Description:

baCopyFile copies a file.

Platforms:

Windows and Macintosh

Usage:

Result = baCopyFile( SourceFile , DestFile , Overwrite )

Arguments:

String, string, string.
SourceFile is the file to copy.
DestFile is the name to copy it to.
Overwrite determines how the copy is done. Can be:

"Always"

always copies the file

"IfNewer"

copies the file if SourceFile is newer than DestFile

"IfNotExist"

copies only if DestFile does not already exist

Returns:

Integer.
Returns 0 if the file was copied successfully, otherwise one of these:

Invalid Source file name

 2 

Invalid Dest file name

Error reading the Source file

Error writing the Dest file

Couldn't create directory for Dest file

Dest file exists

Dest file is newer that Source file

Examples:

Director:
OK = baCopyFile( "c:\data\student.dat" , "c:\data\backup\student.dat" , "IfNewer" )

Authorware:
OK := baCopyFile( "c:\\data\\student.dat" , "c:\\data\\backup\\student.dat" , "IfNewer" )
 

Notes:

By default, this function will not overwrite an existing file if that file is marked as read-only. However, by adding "+" to the "Always" and "IfNewer" options (eg "Always+" or "IfNewer+"), the files will be overwritten if they are read-only.

A return value of 6 (Dest file exists) can only be returned when Overwrite is "IfNotExist".

A return value of 7 (Dest file is newer than Source file) can only be returned when Overwrite is "IfNewer". The other return values can be returned for all Overwrite options.

The "IfNewer" option operates as follows: on Windows: if both files have internal version numbers, then these numbers are used for comparison, otherwise the dates of the two files are used for comparison. On Macintosh, only the file dates are used for comparison.

The DestFile must contain the full name of the file, not just the name of the folder it is being copied to.

The new file will be set to archive and not read-only.

See also:

baCopyXFiles
baXCopy
baCopyFileProgress
baCopyXFilesProgress
baXCopyProgress