// Display a status message dialog box to indicate that we are currently trying to obtain the disk information of the computer.
Frmstatus frmstatusmessage = new frmstatus ();
Frmstatusmessage. Show ("processing ....");
Stringbuilder sb = new stringbuilder ();
// Declare the driveinfo Class Object and use the getdrives method to obtain the current
// The driveinfo type array of all logical disk drives in the system.
Driveinfo [] myalldrives = driveinfo. getdrives ();
Try
{
Foreach (driveinfo mydrive in myalldrives)
{
// Use the isready attribute to determine whether the disk device is ready.
If (mydrive. isready)
{
SB. append ("disk drive letter :");
SB. appendline (mydrive. Name );
SB. append ("disk volume label :");
SB. appendline (mydrive. volumelabel );
SB. append ("disk type :");
SB. appendline (mydrive. drivetype. tostring ());
SB. append ("disk format :");
SB. appendline (mydrive. driveformat );
SB. append ("disk size :");
SB. appendline (mydrive. totalsize. tostring ());
SB. append ("available space :");
SB. appendline (mydrive. availablefreespace. tostring ());
SB. append ("total available space (including Disk Quota ):");
SB. appendline (mydrive. totalfreespace. tostring ());
SB. appendline ("------------------------------------------------------------");
}
}
}
Catch (exception ex)
{
MessageBox. Show (ex. Message );
}
Frmstatusmessage. Close ();
Txtresult. Text = sb. tostring ();