IFile.Copy

Syntax

Copy(Source: String; Destination: String; Overwrite: Boolean);

Parameters

Source. File that must be copied.

Destination. Path corresponding to the directory, to which it must be copied.

Overwrite. Parameter that determines whether file is rewritten if the Destination directory contains a file with the same name. If the parameter is set to False and the file exists, an error message is generated.

Description

The Copy method copies the specified file to the specified directory.

Comments

The Destination parameter can also have name of the created file copy.

Example

Sub UserProc;
Var
    Path: String = "D:\Work\";
Begin
    //Check if file exists
    If File.Exists(Path + "1.xml"Then
        //Check if there is directory, in which file copy is created
        If Not Directory.Exists(Path + "Copy"Then
            Directory.CreateDirectory(Path + "Copy");
        End If;
        //Copy file
        File.Copy(Path + "1.xml", Path + "Copy\1_copy.xml"True);
    End If;
End Sub UserProc;

On executing the example it is checked if the specified file is in the directory. If check results are positive, the file is copied to the directory. If the file with the copy name already exists, it is replaced.

See also:

IFile