DirectoryInfo Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Exposes instance methods for creating, moving, and enumerating through directories and subdirectories. This class cannot be inherited.

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

'Declaration
Public NotInheritable Class DirectoryInfo _
	Inherits FileSystemInfo

The DirectoryInfo type exposes the following members.

  NameDescription
Public methodDirectoryInfoInitializes a new instance of the DirectoryInfo class on the specified path.
Top

  NameDescription
Public propertyAttributesGets or sets the attributes for the current file or directory. (Inherited from FileSystemInfo.)
Public propertyCreationTimeGets or sets the creation time of the current file or directory. (Inherited from FileSystemInfo.)
Public propertyCreationTimeUtcGets or sets the creation time, in coordinated universal time (UTC), of the current file or directory. (Inherited from FileSystemInfo.)
Public propertyExistsGets a value indicating whether the directory exists. (Overrides FileSystemInfo..::..Exists.)
Public propertyExtensionGets the string representing the extension part of the file. (Inherited from FileSystemInfo.)
Public propertyFullNameGets the full path of the directory or file. (Inherited from FileSystemInfo.)
Public propertyLastAccessTimeGets or sets the time the current file or directory was last accessed. (Inherited from FileSystemInfo.)
Public propertyLastAccessTimeUtcGets or sets the time, in coordinated universal time (UTC), that the current file or directory was last accessed. (Inherited from FileSystemInfo.)
Public propertyLastWriteTimeGets or sets the time when the current file or directory was last written to. (Inherited from FileSystemInfo.)
Public propertyLastWriteTimeUtcGets or sets the time, in coordinated universal time (UTC), when the current file or directory was last written to. (Inherited from FileSystemInfo.)
Public propertyNameGets the name of this DirectoryInfo instance. (Overrides FileSystemInfo..::..Name.)
Public propertyParentGets the parent directory of a specified subdirectory.
Public propertyRootGets the root portion of the directory.
Top

  NameDescription
Public methodCreateCreates a directory.
Public methodCreateSubdirectoryCreates a subdirectory or subdirectories on the specified path. The specified path can be relative to this instance of the DirectoryInfo class.
Public methodDelete()()()()Deletes this DirectoryInfo if it is empty. (Overrides FileSystemInfo..::..Delete()()()().)
Public methodDelete(Boolean)Deletes this instance of a DirectoryInfo, specifying whether to delete subdirectories and files.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Public methodGetDirectoriesReturns the subdirectories of the current directory.
Public methodGetFilesReturns a file list from the current directory.
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodMoveToMoves a DirectoryInfo instance and its contents to a new path.
Public methodRefreshRefreshes the state of the object. (Inherited from FileSystemInfo.)
Public methodToStringReturns the original path that was passed by the user. (Overrides Object..::..ToString()()()().)
Top

Use the DirectoryInfo class for typical operations such as copying, moving, renaming, creating, and deleting directories.

If you are going to reuse an object several times, consider using the instance method of DirectoryInfo instead of the corresponding static methods of the Directory class, because a security check will not always be necessary.

NoteNote

In members that accept a path as an input string, that path must be well-formed or an exception is raised. For example, if a path is fully qualified but begins with a space, the path is not trimmed in methods of the class. Therefore, the path is malformed and an exception is raised. Similarly, a path or a combination of paths cannot be fully qualified twice. For example, "c:\temp c:\windows" also raises an exception in most cases. Ensure that your paths are well-formed when using methods that accept a path string.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show: