This class provides many
static methods for working with
filesystem directories. Most of the methods behave as expected.
GetLogicalDrives( ) returns an array of all of the
drives of a system in the format
"k:", in which
"k" is the drive letter.
GetParent( ) returns the parent path of the
specified path, and GetDirectoryRoot( ) returns
the root directory of the specified path.
public sealed class Directory {
// Public Static Methods
public static DirectoryInfo CreateDirectory(string path);
public static void Delete(string path);
public static void Delete(string path, bool recursive);
public static bool Exists(string path);
public static DateTime GetCreationTime(string path);
public static DateTime GetCreationTimeUtc(string path);
public static string GetCurrentDirectory( );
public static string[ ] GetDirectories(string path);
public static string[ ] GetDirectories(string path, string searchPattern);
public static string GetDirectoryRoot(string path);
public static string[ ] GetFiles(string path);
public static string[ ] GetFiles(string path, string searchPattern);
public static string[ ] GetFileSystemEntries(string path);
public static string[ ] GetFileSystemEntries(string path, string searchPattern);
public static DateTime GetLastAccessTime(string path);
public static DateTime GetLastAccessTimeUtc(string path);
public static DateTime GetLastWriteTime(string path);
public static DateTime GetLastWriteTimeUtc(string path);
public static string[ ] GetLogicalDrives( );
public static DirectoryInfo GetParent(string path);
public static void Move(string sourceDirName, string destDirName);
public static void SetCreationTime(string path, DateTime creationTime);
public static void SetCreationTimeUtc(string path, DateTime creationTimeUtc);
public static void SetCurrentDirectory(string path);
public static void SetLastAccessTime(string path, DateTime lastAccessTime);
public static void SetLastAccessTimeUtc(string path, DateTime lastAccessTimeUtc);
public static void SetLastWriteTime(string path, DateTime lastWriteTime);
public static void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc);
}