- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find free disk space using C#
Firstly, create an instance of DriveInfo −
DriveInfo dInfo = new DriveInfo("E");
Display free space −
Console.WriteLine("Disk Free space = {0}", dInfo.AvailableFreeSpace);
Now, use AvailableFreeSpace property and get the percentage of free space −
Double pc = (dInfo.AvailableFreeSpace / (float)dInfo.TotalSize) * 100;
Here, you will get the percentage of free size in comparison with the total disk space −
Console.WriteLine("
Free space (percentage) = {0:0.00}%.", pc);
Advertisements
To Continue Learning Please Login
Login with Google