DADiSP Worksheet Functions > Function Categories > File Manipulation > COPYFILE

 

COPYFILE

Purpose:

Copies one or more files to a destination file or directory.

Syntax: 

COPYFILE("srcname", "desname", overwrite)

"srcname"

-

A string, the name of the file or directory to copy. The name can include * or ? wildcard characters.

"desname"

-

A string, the name of the destination file or directory.

overwrite

-

Optional, an integer confirm delete flag.

0:

Overwrite without confirmation (default).

1:

Confirm overwrite

2:

Do not overwrite.

Returns:

An integer, the count of the number of files successfully copied.

Example:

copyfile("myfun.spl", "myfun.spl.bak")

 

copies the file myfun.spl to myfun.spl.bak in the current directory. If myfile.spl.bak is overwritten if it already exists.

Example:

copyfile("\spldir\*.spl", "E:\splbackup")

 

copies all files with extension .spl in the directory \spldir to the directory E:\splbackup. The number of files copied is returned.

Example:

copyfile("\spldir", "E:\splbackup")

 

copies all files and sub-directories in the directory \spldir to the directory E:\splbackup. The number of files copied is returned.

Remarks:

COPYFILE copies a source file to a destination file or directory. If the source is a directory or resolves to multiple files, the target must also be a directory.

 

If the source name specifies a directory, all of the files and sub-directories are copied to the target directory.

 

The source name may contain the * and ? characters to specify multiple files.

 

See MOVEFILE to move one or more source files or a directory to a new destination and delete the original files.

See Also:

DELFILE

FILEEXISTS

MKDIR

MOVEFILE

RMDIR