O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

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

Manipulate a Directory

Problem

You want to delete, rename, or check if a directory exists. Or, you want to retrieve information about a directory such as its attributes or creation date.

Solution

Create a DirectoryInfo instance for the directory, and use its properties and methods.

Discussion

The DirectoryInfo object works almost the same as the FileInfo object. You can use the same properties for retrieving attributes, names, and file system timestamps. You can also use the same methods for moving, deleting, and renaming directories as you would with files. These members are described in Table 5-1. In addition, the DirectoryInfo object provides some directory-specific members, which are shown in Table 5-3.

Table 5-3. DirectoryInfo Members

Member

Description ...

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