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

Thread: Free disk space and attributes...

  1. #1
    Join Date
    Jun 2009
    Posts
    144

    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
    Last edited by invader7; August 15th, 2009 at 11:23 AM.

  2. #2
    Join Date
    Mar 2008
    Location
    IRAN
    Posts
    811

    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.
    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center