RenameFile()

Syntax

Result = RenameFile(OldFilename$, NewFilename$)
Description
Rename the old file to the new file.

Parameters

OldFilename$ The old name of the file.
NewFilename$ The new name of the file.

Return value

Returns nonzero if the operation succeeded and zero if it failed.

Remarks

The old and new filename do not have to be in the same directory, so this function can be used to move a file to a different directory. This function can also be used to rename/move directories.

Example

  If RenameFile("C:\test.txt", "D:\temp\test_backup.txt")   
    Debug "Moving and renaming successful."    ; Moving and renaming of the file was successful
  Else 
    Debug "Moving and renaming failed."        ; Moving and renaming failed, e.g. because of a not found source file
  EndIf

See Also

CopyFile(), DeleteFile(), CreateFile(), CopyDirectory()

Supported OS

All

<- NextDirectoryEntry() - FileSystem Index - SetCurrentDirectory() ->