Directory.CreateDirectory Method (String, DirectorySecurity)
Creates all the directories in the specified path, applying the specified Windows security.
Assembly: mscorlib (in mscorlib.dll)
public static DirectoryInfo CreateDirectory( string path, DirectorySecurity directorySecurity )
- Type: System.String
The directory to create.
- Type: System.Security.AccessControl.DirectorySecurity
The access control to apply to the directory.
The directory specified by path is a file.
The network name is not known.
The caller does not have the required permission.
path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.
path is prefixed with, or contains only a colon character (:).
path is null.
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 is invalid (for example, it is on an unmapped drive).
path contains a colon character (:) that is not part of a drive label ("C:\").
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.
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.
Creating a directory with only the colon (:) character is not supported and causes a NotSupportedException to be thrown.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.