MkDir Statement
Creates a new directory or folder.
Syntax
MkDir path
path: Required. String expression that identifies the directory or folder to be created. May include drive. If no drive is specified,MkDircreates the new directory or folder on the current drive.
Remarks
- An error occurs if you try to create a directory or folder that already exists
- The
pathargument can include absolute or relative paths - You can use
MkDirto create nested directories by creating parent directories first - On Windows systems, both forward slashes (/) and backslashes () can be used as path separators
- The directory name can include the drive letter
- UNC paths are supported on network drives
Examples
' Create a directory in the current directory
MkDir "MyNewFolder"
' Create a directory with full path
MkDir "C:\Program Files\MyApp"
' Create a directory on another drive
MkDir "D:\Data\Reports"
' Create nested directories (parent must exist first)
MkDir "C:\Temp"
MkDir "C:\Temp\Logs"
MkDir "C:\Temp\Logs\Archive"
' Create directory on network drive
MkDir "\\Server\Share\NewFolder"