IFileInfo.CopyTo

Syntax

CopyTo(Destination: String; Overwrite: Boolean);

Parameters

Destination — path that corresponds to the directory, into which a file must be copied.

Overwrite — parameter that determines whether a file is overwritten, if there is a file with the same name in the Destination directory. If the passed value is True, the file is overwritten. If the passed value is False and the file already exists, an exception is thrown.

Description

The CopyTo method copies a file to a directory passed by the Destination parameter.

Example

Sub Main;

Var

FileInf: IFileInfo;

Begin

FileInf:=New FileInfo.Attach("c:\Work\1.txt");

If FileInf.Exists And Directory.Exists("c:\Temp") Then

FileInf.CopyTo("c:\Temp", True);

End If;

Dispose FileInf;

End Sub Main;

After executing the example a file is copied into the folder C:\Temp.

See also:

IFileInfo