COPYFILE statement

Purpose: Copy file SourceFile$ to DestinationFile$, optionally overwriting an existing file. Useful for making a backup of an existing file.


 Syntax:

 COPYFILE SourceFile$, DestinationFile$ [,TRUE | FALSE]

 Parameters:

  • SourceFile$ Name of file to be copied.
  • DestinationFile$ Name of file to which SourceFile$ is to be copied.
  • TRUE | FALSE Specifies how to proceed if the name CopiedFile$ already exists. If this parameter is TRUE and the new file already exists, the function fails and does not overwrite the existing file. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds. If the optional [,TRUE | FALSE] parameter is not used the default is FALSE and if it exists the file 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"