Driveinfo [] Alldrive =Driveinfo. Getdrives ();// Obtain an array of driveinfo objects, representing all logical partitions of the current computer
Foreach(DriveinfoItemInAlldrive)
{
If(Item. isready)// Check whether the disk space is readable. An exception is not readable.
{
If(Item. Name. toupper (). tostring () ="E :\\")
{
// Item. Name. tostring () +"Disk; "available space:" +
This. Lbllast. Text + = (item. availablefreespace/(1024*1024). tostring () +"MB";
}
}
}
The driveinfo class allows you to obtain information about the computer drive. In general, the driveinfo class is only used to obtain the size of the remaining disk space.
Driveinfo class member
Totalsize: obtains the total size of the drive, in bytes, including allocated and unallocated.
Totalfreespace: obtains the total remaining disk space in bytes.
The size of the available disk space obtained by auailablefreespace, in bytes. However, if you use the disk quota to limit the available space of ASP. NET processes, the available space may be less than the total available space.
Driveformat returns the name of the file system used by the drive (for example, NTFS or FAT32)
Drivetype returns a drivetype enumeration value that indicates whether the drive is fixed, network, CD-ROM, Ram, or removable (unknow is returned if the drive type is not determined)
Isready returns whether the drive is ready for reading or writing
Name returns the drive letter (such as C: Or e :)
Volumelabel returns the drive volume label. In a drive partitioned in NTFS format, the volume tag can contain a maximum of 32 characters. If no value is set, null is returned.
Rootdirectory: returns the directoryinfo object in the root directory of the drive.
Getdrives () gets an array of driveinfo objects, representing all the logical partitions of the current computer.