locked
Disk Partition Free Space RRS feed

  • Question

  • I am attempting to programatically retrieve the free space for all partitions on each disk in any given system.  Using WMI, I have found a way to get the free space for logical drives within Windows but, I have found no way to get the free space for partitions that are hidden to Windows Explorer.  For instance, dell PCs ship with a hidden partition that hold the restore image.  This partition (and it free space) is visible in computer management (disk manager) but I can find nothing in WMI to retrieve this information.

    Is there a way using WMI or other means to retrieve this infomation in a C# windows app?

    Thanks...

    Thursday, November 16, 2006 7:44 PM

Answers

  • if you are using .NET 2.0 you would be better in using the DriveInfo classes as it would be cheaper and quicker than WMI.

    DriveInfo[] theDrives = DriveInfo.GetDrives();

    foreach(DriveInfo currentDrive in theDrives)

    {

       if (currentDrive.DriveType == DriveType.Fixed)

       {

          MessageBox.Show(currentDrive.TotalFreeSpace.ToString());

       }

    }

     

    now in regards for the hidden partition - this is something Windows does low level since its a hidden partition and no drive letter has been assigned, nothing much you can really do unless there is a way to P/Invoke to some Windows library. Those are hidden partitions and special partitions for utilities and tools stored on the system and really not worth measuring as its only a small amount of space being used (a few MB's) as well as not being able to write on the partition I believe

    Thursday, November 16, 2006 8:04 PM

All replies

  • if you are using .NET 2.0 you would be better in using the DriveInfo classes as it would be cheaper and quicker than WMI.

    DriveInfo[] theDrives = DriveInfo.GetDrives();

    foreach(DriveInfo currentDrive in theDrives)

    {

       if (currentDrive.DriveType == DriveType.Fixed)

       {

          MessageBox.Show(currentDrive.TotalFreeSpace.ToString());

       }

    }

     

    now in regards for the hidden partition - this is something Windows does low level since its a hidden partition and no drive letter has been assigned, nothing much you can really do unless there is a way to P/Invoke to some Windows library. Those are hidden partitions and special partitions for utilities and tools stored on the system and really not worth measuring as its only a small amount of space being used (a few MB's) as well as not being able to write on the partition I believe

    Thursday, November 16, 2006 8:04 PM
  • Hi,

     

    I have to findout the available free space for all partitions in any system. I mean I have to findout the unpartitioned space in any system

     

    Can you  help me.

    Thursday, January 11, 2007 9:48 AM
  • I konw some freeware could help allocated your free space to your parititons:paragon and easeus
    partition manager.


    I recommend easeus partition manager worked great on my computer,paragon another free partition manager can't work!

    partition manger:www.partition-tool.com

    Thursday, July 3, 2008 7:30 AM