Previous Topic: RemoveDirectory or RmDir - Remove a DirectoryNext Topic: RenameFile - Rename or Move a File


RenameDirectory or RenDir - Rename or Move a Directory

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

Use the RenameDirectory or RenDir function to rename or move the specified directory.

This file content function has the format:

RenameDirectory(oldname as String, newname as String) as Boolean
RenDir(oldname as String, newname as String) as Boolean
oldname

Specifies the name of an existing directory.

newname

Identifies the new name of the directory.

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

Example: RenameDirectory function

This example creates and renames a directory.

'Create dir
CreateDirectory("C:\AMTest")

'Set active dir
SetDirectory("C:\AMTest")
MessageBox(" Current Directory is : " + GetDirectory(0) )

'Set Default to C:\
SetDirectory("C:\")

'Rename the directory
RenameDirectory("C:\AMTest","C:\AMTest_1")

If ExistDirectory("C:\AMTest_1") THEN
 RemoveDirectory("C:\AMTest_1")

Else
 MessageBox("Could not find directory : C:\AMTest_1")
Endif