2

I have below code to get individual drive's information but I want the whole HDD informationie.I.E. total size and used or available space

public List<DriveInformation> GetDriveInfo()
{
    List<DriveInformation> info = new List<DriveInformation>();
    DriveInfo[] drives = DriveInfo.GetDrives();
    foreach (DriveInfo drive in drives)
    {
        DriveInformation temp = new DriveInformation();
        temp.driveName = drive.Name;
        temp.driveSize = drive.TotalSize.ToString();
        temp.availableSize = drive.TotalFreeSpace.ToString();
        info.Add(temp);
    }
    return info;
}

if I have an unallocated drive then drive info unable to show that space.
ex: I have 500GB HDD and there is 2(C & D) partitions 200 each then this function give only infromation about C and D. I also want the Unallocated space detail(I.E.another 100GB) whether it is used or unallocated.

  • Unallocated space isn't a `drive` though so that's as expected. I beleive WMI will give you partition information in objects like `Win32_DiskPartition` etc. – Lloyd Sep 09 '14 at 05:23
  • This might help my friend :) http://stackoverflow.com/questions/7656857/how-to-get-unallocated-space-info-in-a-physical-disk – Rafał Czabaj Sep 09 '14 at 05:23

0 Answers0