20.4. Working with the Directory Type

You have seen the DirectoryInfo type in action; now you're ready to learn about the Directory type. For the most part, the static members of Directory mimic the functionality provided by the instance-level members defined by DirectoryInfo. Recall, however, that the members of Directory typically return string data rather than strongly typed FileInfo/DirectoryInfo objects.

Now let's look at some functionality of the Directory type; this final helper function displays the names of all drives mapped to the current computer (using the Directory.GetLogicalDrives() method) and uses the static Directory.Delete() method to remove the \MyFolder and \MyFolder2\Data subdirectories created previously:

static void FunWithDirectoryType() ...

Get Pro C# 2010 and the .NET 4 Platform, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.