Share via


MkDir Function 

Creates a new directory.

The My feature gives you greater productivity and performance in file I/O operations than MkDir. For more information, see My.Computer.FileSystem.CreateDirectory Method.

Public Sub MkDir(ByVal Path As String)

Parameters

  • Path
    Required. String expression that identifies the directory to be created. The Path may include the drive. If no drive is specified, MkDir creates the new directory on the current drive.

Exceptions

Exception type Error number Condition

ArgumentException

52

Path is not specified or is empty.

SecurityException

70

Permission denied.

IOException

75

Directory already exists.

See the "Error number" column if you are upgrading Visual Basic 6.0 applications that use unstructured error handling. (You can compare the error number against the Number Property (Err Object).) However, when possible, you should consider replacing such error control with Structured Exception Handling Overview for Visual Basic.

Security noteSecurity Note

Both read and write file I/O permissions are necessary to create a directory or folder. For more information, see FileIOPermission and Code Access Permissions.

Remarks

This function creates a new directory.

Example

This example uses the MkDir function to create a directory. If the drive is not specified, the new directory is created on the current drive.

' Make new directory.
MkDir("C:\TESTDIR")

Smart Device Developer Notes

This function is not supported.

Requirements

Namespace: Microsoft.VisualBasic

Module: FileSystem

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

See Also

Tasks

How to: Create a Directory in Visual Basic

Reference

ChDir Function
CurDir Function
RmDir Function
ArgumentException Class
IOException Class