Visual Basic Language Reference  

RmDir Function

Removes an existing directory or folder.

Public Sub RmDir(ByVal Path As String)

Parameter

Path
Required. String expression that identifies the directory or folder to be removed. Path may include the drive. If no drive is specified, RmDir removes the directory or folder on the current drive.

Exceptions/Errors

Exception type Error number Condition
ArgumentException 52 Path is not specified or is empty.
IOException 75 Target directory contains files.
FileNotFoundException 76 Directory does not exist.

Remarks

An error occurs if you try to use RmDir on a directory or folder containing files. Use the Kill function to delete all files before attempting to remove a directory or folder.

Example

This example uses the RmDir function to remove an existing directory or folder.

' Assume that MYDIR is an empty directory or folder.
RmDir ("MYDIR")   ' Remove MYDIR.

See Also

ChDir Function | CurDir Function | Kill Function | MkDir Function | ArgumentException | IOException | FileNotFoundException