20.3. Working with the DirectoryInfo Type

The first creatable I/O-centric type you will examine is the DirectoryInfo class. This class contains a set of members used for creating, moving, deleting, and enumerating over directories and subdirectories. In addition to the functionality provided by its base class (FileSystemInfo), DirectoryInfo offers the key members in Table 20-3.

Table 20.3. Key Members of the DirectoryInfo Type
MemberMeaning in Life
Create() CreateSubdirectory()Create a directory (or set of subdirectories) when given a path name.
Delete()Deletes a directory and all its contents.
GetDirectories()Returns an array of DirectoryInfo objects that represent all subdirectories in the current directory.
GetFiles()Retrieves an array of FileInfo ...

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.