Free disk space and attributes...
Hello, can you help me with free disk space and folder attributes ? how can i get the size in GB and how can i find the attributes (write,read) on a share ? thanks...
* i know how to find free disk space in bytes.
* it's same in linux partitions and windows? (size and attributes code)
thanks
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);
}