Create Directory Method
The Create Directory method creates a new directory. It does not return a value.
Format
MkDir[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 where this method creates the directory. You can use a letter or a string expression that identifies the drive name. If you do not include the drive argument, then this method creates the new directory on the current drive. If you include the drive argument, then you must include the colon (:). |
\directory\ |
The path to the directory where this method creates the new directory, or a string expression that identifies this path. You can use this argument only if the Create Directory method must not create the directory in the following locations:
|
directory |
The name of the directory that this method creates, or a string expression that identifies this directory name. |
Example
The following example creates 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