[Mono-dev] disk size

Gonzalo Paniagua Javier gonzalo at ximian.com
Mon Dec 5 12:02:06 EST 2005

On Mon, 2005-12-05 at 07:03 -0500, Jonathan Pryor wrote:
> 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);

Environment.GetLogicalDrives will give you all the mount points in the
system (excluding stuff like 'none', 'sysfs', 'tmpfs', 'devpts'...).


More information about the Mono-devel-list mailing list