IFileInfo.MoveTo

Syntax

MoveTo(Destination: String);

Parameters

Destination - path that corresponds to the directory, into which a file must be moved.

Description

The MoveTo method moves a file into the directory passed by the Destination parameter.

Comments

If a file with the same name exists in the specified directory, the current file will be renamed after moving. A new file name is formed as the name of the copy of existing file in accordance with the algorithm contained in operating system.

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.MoveTo("c:\Temp");

End If;

Dispose FileInf;

End Sub Main;

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

See also:

IFileInfo