Directory and DirectoryInfo Classes in VB.NET

In this article I will explain you about Directory and DirectoryInfo Classes in VB.NET.
  • 4083

The Directory and DirectoryInfo classes are used to perform various operations on directories such as Create, Move, Delete, and Enumerate. The functional distinction between these classes is the same as that between the File and FileInfo classes: the Directory class provides static methods whereas the DirectoryInfo class provides instance methods to deal with directories. Below, Table 6.2 compares these directory classes.

Table 6.2: Directory and DirectoryInfo class members


Like the FileInfo class, the DirectoryInfo class also has a single constructor that takes either the full path or relative path to the directory as the input parameter:

Dim d1 As New DirectoryInfo("c:\temp") //Make a directory object

Some important properties of the DirectoryInfo class, such as CreationTime, Exists, FullName, LastAccessTime, LastWriteTime, Name, Parent, and Root, work as their names suggest. For example, CreationTime shows the creation time of the directory. FullName is the full qualified path of the directory, while Name is just the relative folder name without the path (e.g., a directory with the FullName of c:\My Project\test would have a Name of test).


Hope this article would have helped you in understanding Directory and DirectoryInfo Classes in VB.NET.


More Articles

© 2020 DotNetHeaven. All rights reserved.