Redigera

Dela via


FileSystem.CreateDirectory(String) Method

Definition

Creates a directory.

public:
 static void CreateDirectory(System::String ^ directory);
public static void CreateDirectory (string directory);
static member CreateDirectory : string -> unit
Public Shared Sub CreateDirectory (directory As String)

Parameters

directory
String

Name and location of the directory.

Exceptions

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

directory is Nothing or an empty string.

The directory name is too long.

The directory name is only a colon (:).

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

The user does not have permission to create the directory.

Examples

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

Remarks

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

Applies to

See also