const int Removable = 2; const int LocalDisk = 3; const int Network = 4; const int CDRom = 5;
ManagementObjectCollection queryCollection = getDrives();
foreach(ManagementObject mo in queryCollection) { switch(int.Parse( mo["DriveType"].ToString())) { case Removable: //removable drives imageIndex = (int)FileImages.FLOPPYDISK; break; case LocalDisk: //Local drives imageIndex = (int)FileImages.LOCALDISK; break; case CDRom: //CD rom drives imageIndex = (int)FileImages.CDDISK; break; case Network: //Network drives imageIndex = (int)FileImages.Network; break; default: //defalut to folder imageIndex = (int)FileImages.FILE_IMAGE_DEFAULT; break; } //show the drive in the ListView listView.Items.Add(mo["Name"].ToString(),imageIndex); }