PC Review


Reply
Thread Tools Rate Thread

Determine the free space of a mounted volume?

 
 
LowFuel
Guest
Posts: n/a
 
      13th Jun 2006
Anyone know how I can determine the free space of a volume that is
mounted within a folder, rather than on a drive letter?

The DriveInfo class seems to want to work only off drive letters.

What I'm trying to do is write a simple program to generate a disk
space usage report. I have numerous volumes mounted as:

c:\storage\data1
c:\storage\data2
etc....

data1 and data2 above are volumes, not folders, and I want to determine
how much free space each has.

Thanks for any tips...

Jason

 
Reply With Quote
 
 
 
 
jeremiah johnson
Guest
Posts: n/a
 
      14th Jun 2006
WMI is what you need. I only have one disk mounted but this program
worked for me with the one disk:

using System;
using System.Collections;
using System.Text;
using System.Runtime.InteropServices;
using System.Management;

namespace WMITest {
class Program {
static void Main(string[] args) {

foreach(ManagementObject drive in
new ManagementObjectSearcher(
"select * from Win32_DiskDrive").Get()) {

// associate physical disks with partitions
foreach(ManagementObject partition in
new ManagementObjectSearcher(
"ASSOCIATORS OF {Win32_DiskDrive.DeviceID='"
+ drive["DeviceID"]
+ "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition").Get()) {

Console.WriteLine("Partition=" + partition["Name"]);

// associate partitions with logical disks (drive letter volumes)
foreach(ManagementObject disk in
new ManagementObjectSearcher(
"ASSOCIATORS OF {Win32_DiskPartition.DeviceID='"
+ partition["DeviceID"]
+ "'} WHERE AssocClass = Win32_LogicalDiskToPartition").Get()) {

Console.WriteLine("free space="
+ Convert.ToDouble(disk["FreeSpace"])
/ (1024 * 1024) + " Megs.");
}
}
}
}
}
}


LowFuel wrote:
> Anyone know how I can determine the free space of a volume that is
> mounted within a folder, rather than on a drive letter?
>
> The DriveInfo class seems to want to work only off drive letters.
>
> What I'm trying to do is write a simple program to generate a disk
> space usage report. I have numerous volumes mounted as:
>
> c:\storage\data1
> c:\storage\data2
> etc....
>
> data1 and data2 above are volumes, not folders, and I want to determine
> how much free space each has.
>
> Thanks for any tips...
>
> Jason
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Spurious 'low space' warning on XP mounted volume ChrisM Windows XP General 1 5th Sep 2006 01:37 AM
Need Help on adding disk space to Mounted volume in W2K singamalai Microsoft Windows 2000 File System 0 13th Jul 2004 11:55 PM
System volume loses free space Cyndee Meystel Windows XP Hardware 8 11th Jun 2004 02:10 PM
System volume loses free space Cyndee Meystel Windows XP General 10 11th Jun 2004 01:57 PM
Disk Manager - NTFS Mounted Volume not mounted Dave Petika Microsoft Windows 2000 File System 0 1st Aug 2003 06:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:47 PM.