[Mono-dev] disk size

Jonathan Pryor jonpryor at vt.edu
Mon Dec 5 07:03:17 EST 2005

On Mon, 2005-12-05 at 11:27 +0100, mirek wrote:
> in my application i need to get information about the disk size (the 
> total capacity of the disk, the free space left). when i was googling 
> for how-tos, i found the System.Management namespace. but it is not 
> implemented in the mono. so - can anybody help? can i do it directly 
> with mono, or it is need to take a look in the /proc or get output from 
> df utility?

If (1) You only need this functionality on Unix systems, and (2) the
disk you care about is located in /etc/fstab (so that getfsfile(3) can
find it), then you can use Mono.Unix.UnixDriveInfo in Mono.Posix.dll.

        Mono.Unix.UnixDriveInfo info = new UnixDriveInfo ("/");
        Console.WriteLine (" Disk Size: " + info.TotalSize);
        Console.WriteLine ("Free Space: " + info.AvailableFreeSpace);

 - Jon

More information about the Mono-devel-list mailing list