Export (0) Print
Expand All

DirectoryInfo::CreateSubdirectory Method (String, DirectorySecurity)

Creates a subdirectory or subdirectories on the specified path with the specified security. The specified path can be relative to this instance of the DirectoryInfo class.

Namespace:  System.IO
Assembly:  mscorlib (in mscorlib.dll)

public:
DirectoryInfo^ CreateSubdirectory(
	String^ path, 
	DirectorySecurity^ directorySecurity
)

Parameters

path
Type: System::String

The specified path. This cannot be a different disk volume or Universal Naming Convention (UNC) name.

directorySecurity
Type: System.Security.AccessControl::DirectorySecurity

The security to apply.

Return Value

Type: System.IO::DirectoryInfo
The last directory specified in path.

ExceptionCondition
ArgumentException

path does not specify a valid file path or contains invalid DirectoryInfo characters.

ArgumentNullException

path is nullptr.

DirectoryNotFoundException

The specified path is invalid, such as being on an unmapped drive.

IOException

The subdirectory cannot be created.

-or-

A file or directory already has the name specified by path.

PathTooLongException

The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. The specified path, file name, or both are too long.

SecurityException

The caller does not have code access permission to create the directory.

-or-

The caller does not have code access permission to read the directory described by the returned DirectoryInfo object. This can occur when the path parameter describes an existing directory.

NotSupportedException

path contains a colon character (:) that is not part of a drive label ("C:\").

Any and all directories specified in path are created, unless some part of path is invalid. The path parameter specifies a directory path, not a file path. If the subdirectory already exists, this method does nothing.

NoteNote

Path names are limited to 248 characters.

For a list of common I/O tasks, see Common I/O Tasks.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft