Previous Topic: MkDir - File System FunctionNext Topic: RenameDirectory or RenDir - Rename or Move a Directory


RemoveDirectory or RmDir - Remove a Directory

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

The RemoveDirectory or RmDir function removes the directory specified by pathstring.

Note: The specified directory must not be write-protected.

This file content function has the format:

RemoveDirectory(pathstring as String) as Boolean
RemoveDir(pathstring as String) as Boolean
pathstring

Identifies the directory that is to be removed. The specified directory:

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

Example: RemoveDirectory function

This example creates a directory, sets the active directory to it, and gets the name the name of the directory. The example sets the default directory to C:\ and changes the name of the directory created. If the directory exists (that is, it was not renamed), it is deleted.

'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