[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'sysutils' (#rtl)

# RenameFile

Rename a file.

## Declaration

Source position: filutilh.inc line 97

`function RenameFile(`
`const OldName: String;`
`const NewName: String`
`):Boolean;`

## Description

RenameFile renames a file from OldName to NewName. The function returns True if successful, False otherwise. Remark: you cannot rename across disks or partitions.

## Errors

On Error, False is returned.

## See also

DeleteFile |  | Delete a file from the filesystem.

## Example

    Program Example44;

    { This program demonstrates the RenameFile function }

    Uses sysutils;

    Var F : Longint;
        S : String;

    Begin
      S:='Some short file.';
      F:=FileCreate ('test.dap');
      FileWrite(F,S[1],Length(S));
      FileClose(F);
      If RenameFile ('test.dap','test.dat') then
        Writeln ('Successfully renamed files.');
    End.

The latest version of this document can be found at lazarus-ccr.sourceforge.net.