See Also: See Also: File_Exist, EraseFile, File I/O Commands, Copy_DB
Copies one or more disk files
CopyFile {source-file(s)} to {destination}
Where
{source-file(s)} is the specification of a file or set of files (including wildcard characters), optionally including a path.
{destination} is the specification of a file, set of files, folder or drive to copy {source-file(s)} to, optionally including a path.
CopyFile copies the file(s) identified by {source-file(s)} to the file, folder, or drive identified by {destination}, creating any destination files which do not already exist, and overwriting any that do. CopyFile will use the current working folder, unless a path is provided as part of {source-file(s)} and/or {destination}. You may use any valid Windows file specification (including wildcard characters) for {source-file(s)}.
This sample copies the file "foo.txt" in the current working folder to a file named "foo2.txt" in the same folder:
CopyFile "foo.txt" to "foo2.txt"
This sample copies all files with file name "foo" and any file extension to folder "C:\MyFoo":
CopyFile "foo.*" to "C:\MyFoo"
This sample copies the file "foo.txt" to drive "F:":
CopyFile "foo.txt" to "F:"
This is sample copies all files with file name "vendor" and any file extension to a backup folder:
Procedure BackupVendorData
String sDataFolder
// replace {Revision} with DataFlex version, e.g. "14.1"
Move "C:\DataFlex {Revision} Examples\Order Entry\Data" to sDataFolder
Set_Directory sDataFolder
Make_Directory "Backup"
// Copy Vendor table to backup folder
CopyFile "Vendor.*" to "Backup"
End_Procedure
Send BackupVendorData
If a CopyFile command is executed on a non existent source file(s), no error will be triggered. Use the File_Exist command to determine whether a file exists before copying the file(s).
If a CopyFile command is executed on source file(s) that already exist in the destination location, no error, warning or notification will be triggered. Use the File_Exist command to determine whether a file exists in the destination location before copying the file(s).
You may use wildcard characters in the source file specification, but not in the destination file specification. When {source-file(s)} contains ambiguous file names, {destination} must not be ambiguous.
CopyFile does not copy subfolders. You will have to write code to recurse through subfolders you wish to copy, test for their existence using File_Exist and create them yourself using Make_Directory.