EN
Dieser Inhalt ist in Ihrer Sprache leider nicht verfügbar. Im Folgenden finden Sie die englische Version.

Directory Class

July 28, 2014

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

System.Object
  System.IO.Directory

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

public static class Directory

The Directory type exposes the following members.

  NameDescription
Public methodStatic memberCreateDirectoryCreates all directories and subdirectories as specified by path.
Public methodStatic memberDelete(String)Deletes an empty directory from a specified path.
Public methodStatic memberDelete(String, Boolean)Deletes the specified directory and, if indicated, any subdirectories and files in the directory.
Public methodStatic memberExistsDetermines whether the given path refers to an existing directory on disk.
Public methodStatic memberGetCreationTimeGets the creation date and time of a directory.
Public methodStatic memberGetCurrentDirectoryGets the current working directory of the application.
Public methodStatic memberGetDirectories(String)Gets the names of subdirectories (including their paths) in the specified directory.
Public methodStatic memberGetDirectories(String, String)Gets an array of directories (including their paths) that match the specified search pattern in the current directory.
Public methodStatic memberGetDirectoryRootReturns the volume information, root information, or both for the specified path.
Public methodStatic memberGetFiles(String)Returns the names of files in the specified directory.
Public methodStatic memberGetFiles(String, String)Returns the names of files in the specified directory that match the specified search pattern.
Public methodStatic memberGetFileSystemEntries(String)Returns the names of all files and subdirectories in the specified directory.
Public methodStatic memberGetFileSystemEntries(String, String)Returns an array of file system entries matching the specified search criteria.
Public methodStatic memberGetLastAccessTimeReturns the date and time the specified file or directory was last accessed.
Public methodStatic memberGetLastWriteTimeReturns the date and time the specified file or directory was last written to.
Public methodStatic memberMoveMoves a file or a directory and its contents to a new location.
Public methodStatic memberSetCurrentDirectorySecurity Critical. Sets the application's current working directory to the specified directory.
Top

Use the Directory class for typical operations such as copying, moving, renaming, creating, and deleting directories. You can also use the Directory class to get and set DateTime information related to the creation, access, and writing of a directory.

Because all Directory methods are static, it might be more efficient to use a Directory method rather than a corresponding DirectoryInfo instance method if you want to perform only one action. Most Directory methods require the path to the directory that you are manipulating.

The static methods of the Directory class perform security checks on all methods. If you are going to reuse an object several times, consider using the corresponding instance method of DirectoryInfo instead, because the 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; however, if a path is fully qualified but begins with a space, the space is not omitted but no 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.

In members that accept a path, the path can refer to a file or just a directory.

Version Notes

Windows Phone

This type is present to support the .NET Compact Framework infrastructure in Windows Phone, and it is not intended to be used in your application code.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

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

Anzeigen:
© 2014 Microsoft