1, Code Code
System. Io. driveinfo [] Drive = System. Io. driveinfo. getdrives ();
For ( Int I = 0 ; I < Drive. length; I ++ )
{
If (Drive [I]. drivetype = Drivetype. Fixed)
{
Dsmch = Drive [I]. Name;
Double TMP = Drive [I]. totalsize / 1024 / 1024 / 1024 * 100 ;
TMP = Format. Round (TMP, 2 ) / 100 ;
Zhrl = TMP. tostring ();
TMP = Drive [I]. availablefreespace / 1024 / 1024 / 1024 * 100 ;
TMP = Format. Round (TMP, 2 ) / 100 ;
Kyrl = TMP. tostring ();
SQL = " Insert diskdoc (dsmch, zhrl, kyrl) " ;
SQL + = " Values (' " + Dsmch + " ',' " + Zhrl + " ',' " + Kyrl + " ') " ;
CMD = New Sqlcommand (SQL, sqlcon );
Cmd. executenonquery ();
}
}
2. Description
Name: drive letter
Totalfreespace: Return the available disk space. The return value type is long.
drivetype: disk type the returned value is as follows:
CDROM (optical drive) , fixed (Fixed Disk) , unknown (unknown disk) , network (Network Disk) , norootdirectory (the drive letter does not exist) , RAM (Virtual Disk) , removable (removable disk ).
isready : get a value indicating whether the drive is ready return bool type.
rootdirectory : get the root directory of the drive.
totalsize : total space size.
Volumelabel:Returns the string type.
Driveformat: Obtain the name of the file system, such as NTFS or FAT32.