O'Reilly logo

C# in a Nutshell by Peter Drayton, Ted Neward, Ben Albahari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Directory

Synopsis

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 method DirectoryInfo CreateDirectory(
        string path);  
   public static method void Delete(string path);  
   public static method void Delete(string path, 
        bool recursive);  
   public static method bool Exists(string path);  
   public static method DateTime GetCreationTime(
        string path);  
   public static method string GetCurrentDirectory();  
   public static method string[] GetDirectories(string path);  
   public static method string[] GetDirectories(string path, 
        string searchPattern);  
   public static method string GetDirectoryRoot(string path);  
   public static method string[] GetFiles(string path);  
   public static method string[] GetFiles(string path, 
        string searchPattern);  
   public static method string[] GetFileSystemEntries(
        string path);  
   public static method string[] GetFileSystemEntries(
        string path, string searchPattern);  
   public static method DateTime GetLastAccessTime(
        string path);  
   public static method DateTime GetLastWriteTime(
        string path);  
   public static method string[] GetLogicalDrives();  
   public static method DirectoryInfo GetParent(string path ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required