Previous Topic: RenameDirectory or RenDir - Rename or Move a DirectoryNext Topic: SetFileAttributes - Set the File Attributes


RenameFile - Rename or Move a File

Valid on NetWare, Symbian OS, UNIX, Windows and Windows CE

Use the RenameFile or RenFile function to rename or move the specified file.

This file content function has the format:

RenFile(oldname as String, newname as String) as Boolean
RenameFile(oldname as String, newname as String) as Boolean
oldname

Specifies the name of an existing file.

newname

Identifies the new name of the file.

On successful completion, the function returns TRUE; otherwise, it returns FALSE.

Example: RenameFile function

This example creates a backup directory and copies autoexec.bat to the directory and renames it to autoexec.bat.

HELP_GETFILEATTRIBUTES

If Not(ExistDirectory("c:\backup")) then CreateDirectory("c:\backup")
CopyFile("c:\autoexec.bat", "c:\backup\autoexec.bat") 
RenameFile("c:\backup\autoexec.bat", "c:\backup\autoexec.bak")