1 out of 1 rated this helpful - Rate this topic

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)
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.

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 note Security 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.

This function creates any new directories specified in Path, unless they already exist or if some part of Path is invalid. The Path parameter must specify a directory path, not a file path.

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")


This function is not supported.

Namespace: Microsoft.VisualBasic

Module: FileSystem

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

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Run-time error '76': Path not found
If you receive this error, it means that your path up to the directory you are creating is invalid. For example, you are attempting to create "C:\Test Folder\NewOutput\". If you receive error 76, it means that the "Test Folder" directory does not exist. You would have to create "C:\Test Folder\" first and then create the "New Output" directory under "Test Folder".

MkDir will not create the full path to the new directory; it will only attempt to create the final directory contained in the path.