|
-
August 16th, 2009, 04:33 AM
#2
Re: Free disk space and attributes...
you only need some math calculation to get free space in GB:
Code:
private void button1_Click(object sender, EventArgs e)
{
ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid='e:'");
disk.Get();
double diskSize = (ulong)disk["Size"] / (Math.Pow(1024, 3));
double diskFree = (ulong)disk["FreeSpace"] / (Math.Pow(1024, 3));
double percentFree = (diskFree * 100) / diskSize;
label1.Text = String.Format("Your Total Disk Size on Drive E is: {0:#.##} Giga Bytes", diskSize);
label2.Text = String.Format("Your Free Disk Space on Drive E is: {0:#.##} %", percentFree);
}
Please rate my post if it was helpful for you.  Java, C#, C++, PHP, ASP.NET
SQL Server, MySQL
DirectX
MATH Touraj Ebrahimi
[toraj_e] [at] [yahoo] [dot] [com]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|