Remove Directory Method
The Remove Directory method removes a directory. It does not return a value. Note the following:
The directory that it removes must be empty, except for the working directory or parent directory.
It cannot remove the default directory. To remove the default directory, you must first make another directory current on the drive.
Format
RmDir[drive:][\directory\]directory
The following table describes the arguments that you can use with this method.
Argument | Description |
---|---|
drive |
Optional. The name of the drive that contains the directory that this method removes. You can use a letter or a string expression that identifies the drive name. |
\directory\ |
The path to the directory that this method removes. You can use this argument only if the Remove Directory method must not remove the directory from the following locations:
|
directory |
The name of the directory that this method removes. |
Example
The following example makes a new temporary directory in the C:\ directory, and then deletes it:
Sub Button_Click
Dim path as String
On Error Resume Next
path = CurDir(C)
If path <> "C:\" then
ChDir "C:\"
End If
MkDir "C:\TEMP01"
If Err = 75 then
Else
RmDir "C:\TEMP01"
End If
End Sub