Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
DirectoryInfo Constructor
Collapse the table of content
Expand the table of content

DirectoryInfo Constructor

Initializes a new instance of the DirectoryInfo class on the specified path.

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

new : 
        path:string -> DirectoryInfo

Parameters

path
Type: System.String

A string specifying the path on which to create the DirectoryInfo.

ExceptionCondition
ArgumentNullException

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

SecurityException

The caller does not have the required permission.

ArgumentException

path contains invalid characters such as ", <, >, or |.

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.

This constructor does not check if a directory exists. This constructor is a placeholder for a string that is used to access the disk in subsequent operations.

The path parameter can be a file name, including a file on a Universal Naming Convention (UNC) share.

Caution noteCaution

When you compile a set of characters with a particular cultural setting and retrieve those same characters with a different cultural setting, the characters might not be interpretable, and could cause an exception to be thrown.

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

The following example uses this constructor to create the specified directory and subdirectory, and demonstrates that a directory that contains subdirectories cannot be deleted.

No code example is currently available or this language may not be supported.

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Show:
© 2015 Microsoft