We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.

How to: Determine a Directory's Creation Time in Visual Basic

The GetDirectoryInfo method returns a DirectoryInfo object that can be queried for information about the directory.

If the directory does not exist, an exception is not thrown until the first time a property on the DirectoryInfo object is accessed.


Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To determine a directory's creation time

  • Use the GetDirectoryInfo method to retrieve a DirectoryInfo object for the directory, and query the CreationTime property. This example displays CreationTime for C:\Documents and Settings.

    Dim getInfo = My.Computer.FileSystem.GetDirectoryInfo(
                    "C:\Documents and Settings")
    MsgBox("The directory was created at " & getInfo.CreationTime)

The following conditions may cause an exception:

  • The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\.\) (ArgumentException).

  • The path is not valid because it is Nothing (ArgumentNullException).

  • The path exceeds the system-defined maximum length (PathTooLongException).

  • A file or directory name in the path contains a colon (:) or is in an invalid format (NotSupportedException).

  • The user lacks the necessary permissions to view the path (SecurityException).