.NET FRAMEWORK CLASSES

The System.IO namespace provides several classes for working with the filesystem. The Directory and File classes provide shared methods that you can use to manipulate the filesystem without creating instances of helper objects.

The DirectoryInfo and FileInfo classes let you work with specific relevant filesystem objects. For example, a FileInfo object represents a particular file and provides methods to create, rename, delete, and get information about that file.

The following sections describe these and the other classes that the Framework provides to help you work with the filesystem.

Directory

The Directory class provides shared methods for working with directories. These methods let you create, rename, move, and delete directories. They let you enumerate the files and subdirectories within a directory, and get and set directory information such as the directory’s creation and last access time.

The following table describes the Directory class’s shared methods:

METHOD PURPOSE
CreateDirectory Creates a directory and any missing ancestors (parent, grandparent, and so on).
Delete Deletes a directory and its contents. It can delete all subdirectories, their subdirectories, and so forth to remove the entire directory tree.
Exists Returns True if a path points to an existing directory.
GetCreationTime Returns a directory’s creation date and time.
GetCreationTimeUtc Returns a directory’s creation date and time in Coordinated Universal Time (UTC). ...

Get Visual Basic 2012 Programmer's Reference now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.