System.IO.Directory.CreateDirectory Method

Creates all the directories in the specified path, unless the already exist, applying the specified Windows security.

Syntax

public static DirectoryInfo CreateDirectory (string path, System.Security.AccessControl.DirectorySecurity directorySecurity)

Parameters

path
The directory to create.
directorySecurity
The access control to apply to the directory.

Returns

An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.

Remarks

Use this method overload to create a directory with access control, so there is no chance the directory can be accessed before security is applied.

Any and all directories specified in the path parameter are created, unless they already exist or unless some part of path is invalid. The path parameter specifies a directory path, not a file path. If the directory already exists, this method does not create a new directory, but it returns a System.IO.DirectoryInfo object for the existing directory.

Trailing spaces are removed from the end of the path parameter before creating the directory.

You can create a directory on a remote computer, on a share that you have write access to. UNC paths are supported; for example, you can specify the following for path: \\2009\Archives\December in Visual Basic, and \\\\2009\\Archives\\December in C#.

Creating a directory with only the colon character (:) is not supported and causes a NotSupportedException to be thrown.

Requirements

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0