DirectoryInfo.CreateSubdirectory Method
Microsoft Silverlight will reach end of support after October 2021. Learn more.
When it is called by trusted applications, creates a subdirectory or subdirectories on the specified path.
Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
<SecuritySafeCriticalAttribute> _
Public Function CreateSubdirectory ( _
path As String _
) As DirectoryInfo
[SecuritySafeCriticalAttribute]
public DirectoryInfo CreateSubdirectory(
string path
)
Parameters
- 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.
Exceptions
Exception | Condition |
---|---|
ArgumentException | path does not specify a valid file path or contains invalid DirectoryInfo characters. |
ArgumentNullException | path is nulla null reference (Nothing in Visual Basic). |
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:\"). |
Remarks
The specified path can be relative to this instance of the DirectoryInfo class.
Platform Notes
Silverlight for Windows Phone
This member has a SecurityCriticalAttribute attribute on Silverlight for Windows Phone, because the attribute was present in Silverlight 3. This attribute restricts this member to internal use. Application code that uses this member throws a MethodAccessException.
Version Information
Silverlight
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
XNA Framework
Supported in: Xbox 360, Windows Phone OS 7.0
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.