Duplicates a specified file.

Syntax

<oRef>.copy(<filename expC>, <new name expC>)

<oRef>

A reference to a File object.

<filename expC>

Identifies the file to duplicate (also known as the source file). <filename expC> may be a file name skeleton with wildcard characters. In that case, dBASE Plus displays a dialog box in which you select the file to duplicate.

If you specify a file without including its path, dBASE Plus looks for the file in the current directory, then in the search path(s) you specified with SET PATH, if any. If you specify a file without including its extension, dBASE Plus assumes no extension. If the named file cannot be found, an exception occurs.

<new name expC>

Identifies the target file that will be created or overwritten by copy( ). <new name expC> may be a filename skeleton with wildcard characters. In that case, dBASE Plus displays a dialog box in which you specify the name of the target file and its directory.

Property of

File

Description

copy( ) lets you duplicate an existing file at the operating system level. copy( ) duplicates a single file of any type.

When running a PLUS.exe, copy( ) first looks for <filename expC> in the internal file system of the .EXE file. Any path in <filename expC> is ignored. If the named file is found in the .EXE, that file is copied. If the file is not found, then dBASE Plus searches for the file on disk. This lets you package static files, like empty tables, inside the .EXE during the build process and extract them when needed. You cannot copy files into the .EXE

If SET SAFETY is ON and a file exists with the same name as the target file, dBASE Plus displays a dialog box asking if you want to overwrite the file. If SET SAFETY is OFF, any existing file with the same name is overwritten without warning.

copy( ) does not automatically copy the auxiliary files associated with table files, such as indexes and memo files. For example, it does not copy the MDX or DBT file associated with a DBF file. When copying tables, use the Database object’s copyTable( ) method.

You cannot copy( ) a file that has been opened for writing with the open( ) or create ( ) methods; it must be closed first.