FILE.COPY Function
Syntax
Arguments
- source_filenameCharacter
The path and name of the file to copy.
- dest_filenameCharacter
The path and name of the new file.
Description
Copies a file.
Discussion
The FILE.COPY() method copies Source_Filename to the Destination_Filename. If you copy files between specific drives and directories, include the full drive and path with each filename.
You can use this method to duplicate any type of file, including tables, sets, and applications. However, to copy a table, set, or application you must remember to copy all related support files. For a table this can be up to six files: the table itself (.DBF), the memo file (.FPT), the index file (.CDX), and, if present, the three files that make up the data dictionary (.DDD, .DDM, .DDX). When copying tables it is easier to use the <TBL>.DUPLICATE() method instead, since duplicating a table automatically duplicates all support files and data dictionaries.
Example
This statement copies a file into the data directory.
FILE.COPY("c:\a5\defaults.txt","c:\a5\data\defaults.txt")
The following script copies the CUSTOMER table 'and its support files (index and memo file, but not dictionary files) from one directory to another.
filename1 = "C:\A5\A_SPORTS\CUSTOMER.DBF" 'the table file filename2 = "C:\A5\A_SPORTS\CUSTOMER.CDX" 'the index file filename3 = "C:\A5\A_SPORTS\CUSTOMER.FPT" 'the memo field file newfilename1 = "C:\A5\DATA\CLIENTS.DBF" newfilename2 = "C:\A5\DATA\CLIENTS.CDX" newfilename3 = "C:\A5\DATA\CLIENTS.FPT" FILE.copy(filename1,newfilename1) FILE.copy(filename2,newfilename2) FILE.copy(filename3,newfilename3)
See Also