
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
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);
- Related Articles
- Find free disk space using Java
- BleachBit – A Free Disk Space Cleaner
- C# Program to get free space in a drive
- Tracking Down Where Disk Space Has Gone on Linux
- Get the free space of this partition in Java
- C-LOOK Disk Scheduling Algorithm
- How to find the disk type of the Azure Availability set using PowerShell?
- How to format the disk using PowerShell?
- Can I query how much disk space certain rows or columns are taking up in MySQL?
- Find duplicate in an array in O(n) and by using O(1) extra space in C++
- C-LOOK vs C-SCAN Disk Scheduling Algorithm
- How to get the disk information using PowerShell?
- How to get the disk performance using PowerShell?
- Checking data disk, log disk and Trace disk in SAP HANA
- How to find out which processes are using swap space in Linux?

Advertisements