
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Querying Information for All Drives on a System
|
745
The CompareFileVersions method first compares the FileMajorPart version informa-
tion of the two files. If these are equal, the
FileMinorPart version information of the
two files is compared. This continues through the
FileBuildPart and finally the
FilePrivatePart version information values. If all four parts are equal, the files are
considered to have the same version number. If either file is found to have a higher
number than the other file, it is considered to be the latest version.
See Also
See the “FileVersionInfo Class” topic in the MSDN documentation.
12.26 Querying Information for All Drives on a System
Problem
Your application needs to know if a drive (HDD, CD drive, DVD drive, etc.) is avail-
able and ready to be written to and/or read from. Additionally, it would be nice to
know if you have enough available free space on the drive to write information to.
Solution
Use the various properties in the DriveInfo class as shown here:
public static void DisplayAllDriveInfo( )
{
foreach (DriveInfo drive in DriveInfo.GetDrives( ))
{
if (drive.IsReady)
{
Console.WriteLine("Drive " + drive.Name + " is ready.");
Console.WriteLine("AvailableFreeSpace: " + drive.AvailableFreeSpace);
Console.WriteLine("DriveFormat: " + drive.DriveFormat); ...