The System.IO.DriveInfo Class

Similarly to System.IO.DirectoryInfo, System.IO.DriveInfo provides access to the drive’s information. Using this class is straightforward; it provides information on the disk type, disk space (free and total), volume label, and other self-explanatory properties that you can discover with IntelliSense. The following example shows how you can create an instance of the class and retrieve information on the specified drive:

Sub DriveInfoDemo()    Dim dr As New DriveInfo("C:\")    Console.WriteLine("Drive type: {0}", dr.DriveType.ToString)    Console.WriteLine("Volume label: {0}", dr.VolumeLabel)    Console.WriteLine("Total disk space: {0}", dr.TotalSize.ToString)    Console.WriteLine("Available ...

Get Visual Basic 2015 Unleashed 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.