DirectoryInfo.CreateSubdirectory Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Creates a subdirectory or subdirectories on the specified path.

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


Public Function CreateSubdirectory ( _
    path As String _
) As DirectoryInfo
public DirectoryInfo CreateSubdirectory(
    string path


  • path
    Type: System..::.String
    The specified path. This cannot be a different disk volume or Universal Naming Convention (UNC) name.

Return Value

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


Exception Condition

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


path is nullNothingnullptra null reference (Nothing in Visual Basic).


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


The subdirectory cannot be created.


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


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.


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


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.


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


The specified path can be relative to this instance of the DirectoryInfo class.

Version Notes

Windows Phone

This member has a SecurityCriticalAttribute attribute. This attribute restricts this member to internal use. Application code that uses this member throws a MethodAccessException.

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0


Windows Phone

See Also


DirectoryInfo Class

System.IO Namespace