FileSystem.CreateDirectory Method (String)

 

Creates a directory.

Namespace:   Microsoft.VisualBasic.FileIO
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public static void CreateDirectory(
	string directory
)

Parameters

directory
Type: System.String

Name and location of the directory.

Exception Condition
ArgumentException

The directory name is malformed. For example, it contains illegal characters or is only white space.

ArgumentNullException

directory is Nothing or an empty string.

PathTooLongException

The directory name is too long.

NotSupportedException

The directory name is only a colon (:).

IOException

The parent directory of the directory to be created is read-only

UnauthorizedAccessException

The user does not have permission to create the directory.

If the directory already exists, no exception is thrown.

The following table lists an example of a task involving the My.Computer.FileSystem.CreateDirectory method.

To

See

Create a directory

How to: Create a Directory in Visual Basic

This example creates the directory, NewDirectory, in C:\Documents and Settings\All Users\Documents.

My.Computer.FileSystem.CreateDirectory(
  "C:\Documents and Settings\All Users\Documents\NewDirectory")

FileIOPermission

Controls the ability to access files and folders. Associated enumeration: Unrestricted.

.NET Framework
Available since 2.0
Return to top
Show: