This documentation is archived and is not being maintained.

RmDir Function

Removes an existing directory or folder.

Public Sub RmDir(ByVal Path As String)


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.


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.


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.


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.

Smart Device Developer Notes

This function is not supported.


Namespace: Microsoft.VisualBasic

Module: FileSystem

Assembly: Microsoft Visual Basic .NET Runtime (in MicrosoftVisualBasic.dll)

See Also

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