5.1. Retrieve Information About a File, Directory, or Drive

Problem

You need to retrieve information about a file, directory, or drive.

Solution

Create a new System.IO.FileInfo, System.IO.DirectoryInfo, or System.IO.DriveInfo object, depending on the type of resource about which you need to retrieve information. Supply the path of the resource to the constructor, and then you will be able to retrieve information through the properties of the class.

How It Works

To create a FileInfo, DirectoryInfo, or DriveInfo object, you supply a relative or fully qualified path to the constructor. You can also use the GetFileInfo, GetDirectoryInfo, and GetDriveInfo Shared methods of the My.Computer.FileSystem. These methods return an instance of a FileInfo, ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach 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.