FILE.COPY2 Function
Syntax
Arguments
- source_filenameCharacter
The path and name of the file to copy.
- dest_filenameCharacter
The path and name of the new file.
- only_copy_if_newerLogical
Default = .F. Alpha Anywhere checks to see that the source file is newer than the target file before it copies source to target.
Returns
- ResultLogical
Returns .T. if the copy succeeds, otherwise .F..
Description
Same as File.Copy(), but if the dest_filename folder does not exist, then creates it.
Discussion
The FILE.COPY2() 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. If the folder(s) for the target file does not yet exist, the method will create it.
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.
This statement copies a file into the data directory.
FILE.copy2("c:\myfile.txt","c:\backup\data\myfile2.txt")
The function will create c:\backup if it does not exist and will create c:\backup\data if it does not exist.
See Also