Cicode Programming Reference > Cicode Function Categories > File Functions Introduction > FileCopy

FileCopy

Copies a file. You can use the DOS wild card characters (*) and (?) to copy groups of files. In asynchronous Mode, this function will return immediately and the copy will continue in the background. Unless you are accessing to the floppy drive, copying files does not interfere with the operation of other CitectSCADA tasks, because this function is time-sliced.

Syntax

FileCopy(Source, Dest, Mode)

Source:

The name of the source file to copy.

Dest:

The name of destination file to copy to. To copy a file to the printer, specify the name as "LPT1.DOS".

Mode:

The copy mode:

0 - Normal

1 - Copy only if the file time is different.

2 - Copy in asynchronous mode.

Multiple modes can be selected by adding them together (for example, set Mode to 3 to copy in asynchronous mode if the file time is different).

Return Value

0 (zero) if successful, otherwise an error is returned. However, if you copy in asynchronous mode, the return value does not reflect whether the copy operation was successful or not, because the function returns before the actual copy is complete.

Related Functions

FileDelete

Example

! Copy Report.Txt to Report.Bak.
FileCopy ("C:\Data\Report.Txt", "C:\Data\Report.Bak",0);
/* Copy AlarmLog.Txt to AlarmLog.Bak only if the file time is different. Copy in the background. */
FileCopy ("AlarmLog.Txt", "AlarmLog.Bak",1+2);

See Also

File Functions