Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
how to identify that 90 % of disk space is occupied in asp.net and put a msg box for cleanup.Please help
Posted

This will give you the free space percentage:
C#
    Console.WriteLine(GetFreePercentage(@"C:\"));
    ...
private double GetFreePercentage(string driveName)
    {
    foreach (DriveInfo drive in DriveInfo.GetDrives())
        {
        if (drive.IsReady && drive.Name == driveName)
            {
            return ((double)drive.AvailableFreeSpace / (double)drive.TotalSize) * 100;
            }
        }
    return -1.0;
    }
All you have to do is call it when you need to know...
 
Share this answer
 
it can help you for sure..
driveinfo[^]
 
Share this answer
 
You can use DriveInfo class to get all drive. Then check AvailableFreeSpace property to get available space for each drive & TotalSize property to get total size of each drive.
You can calculate percentage in your application once you get drive info.

Refer this link
http://stackoverflow.com/questions/3210010/how-to-calculate-free-disk-space
http://stackoverflow.com/questions/1393711/c-sharp-get-free-disk-space
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900