Search:
Namespaces
Discussions
.NET v1.1
Feedback
Disk full
Messages
Related Types
This message was discovered on
ASPFriends.com 'ngfx-io' list
.
Erik Brown
-- Moved from [winforms-cs] to [ngfx-io] by Charles M. Carroll <
Click here to reveal e-mail address
> --
Can anyone tell me a .NET way to determine information about a specific
disk. For example, total disk size, space used, space free, etc.
Thanks,
Erik Brown
Reply to this message...
Dennis West
here a way from Mac goto
http://aspalliance.com/dotnetsolutions
/GetSolution.aspx?ID=12074" target="_blank">
http://aspalliance.com/dotnetsolutions
/GetSolution.aspx?ID=12074
Over 2000 Asp.Net solutions @
http://aspalliance.com/dotnetsolutions
----- Original Message -----
From: "Erik Brown" <
Click here to reveal e-mail address
>
To: "ngfx-io" <
Click here to reveal e-mail address
>
Sent: Thursday, April 25, 2002 11:33 AM
Subject: [ngfx-io] Disk full
> -- Moved from [winforms-cs] to [ngfx-io] by Charles M. Carroll
<
Click here to reveal e-mail address
> --
[Original message clipped]
Reply to this message...
Erik Brown
Found my own answer (see C# code below), so never mind....
using System;
using System.Management;
class PercentFree
{
[STAThread]
static void Main(string[] args)
{
ManagementObject disk = new
ManagementObject
("win32_logicaldisk.deviceid=\"c:\"");
disk.Get();
// Note: parameters taken from the WMI Win32_LogicalDisk
class
UInt64 size =
Convert
.ToUInt64(disk["Size"]);
UInt64 free =
Convert
.ToUInt64(disk["FreeSpace"]);
double percent = ((double)free/(double)size) * 100.0;
Console.WriteLine("Logical Disk Size = " + size +
"bytes");
Console.WriteLine("Free Space = " + free + " bytes");
Console.WriteLine("Percent Free = " +
percent.ToString("##.##") + "%");
Console.WriteLine("\nPress <Return> to exit.");
Console.ReadLine();
}
}
[Original message clipped]
Reply to this message...
System.Console
System.Convert
System.Management.ManagementObject
System.UInt64
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com