Free disk space and attributes...
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: Free disk space and attributes...

  1. #1
    Join Date
    Jun 2009

    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)

    Last edited by invader7; August 15th, 2009 at 10:23 AM.

  2. #2
    Join Date
    Mar 2008

    Re: Free disk space and attributes...

    you only need some math calculation to get free space in GB:

      private void button1_Click(object sender, EventArgs e)
                ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid='e:'");
                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
    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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)