COPYFILE statement

Purpose:

COPYFILE will create a copy of a file, optionally overwriting an existing file.

VBA's FILECOPY reserved word can be used as an alias to BCX's COPYFILE statement.

Syntax:

COPYFILE SourceFile AS STRING, DestinationFile AS STRING [, TRUE | FALSE]

Parameters:

  • Data type: STRING
    SourceFile Name of file to be copied.
  • Data type: STRING
    DestinationFile Name of file to which SourceFile is to be copied.
  • TRUE | FALSE Specifies how to proceed if the DestinationFile already exists. If this parameter is set to TRUE and the new file already exists, COPYFILE does not overwrite the existing file. If this parameter is FALSE and the DestinationFile already exists, COPYFILE overwrites the existing file. If the optional [, TRUE | FALSE] parameter is not specified, the default is FALSE and an existing DestinationFile will be overwritten.

Example 1:

Src$ = "c:\bcx\gui_demo\calendar\cal.exe"
Dest$ = "c:\test\cal.exe"
COPYFILE Src$, Dest$  ' 3rd parameter is implicitly FALSE

Example 2:

Src$ = "c:\bcx\gui_demo\calendar\cal.exe"
Dest$ = "c:\test\cal.exe"
COPYFILE Src$, Dest$, FALSE ' 3rd parameter is explicitly FALSE

Example 3 :

COPYFILE "c:\bcx\gui_demo\calendar\cal.exe","c:\test\cal.exe"