Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get complete drive information using C#?
Drive information of an Operating System includes.
Drive Name Volume Label Free Space Total Size Drive Format Drive Type
To get above information about a drive, try to run the following code −
Example
using System.IO;
using System;
class Program {
static void Main() {
DriveInfo driveInfo = new DriveInfo("D");
Console.WriteLine(driveInfo.Name);
Console.WriteLine(driveInfo.VolumeLabel);
Console.WriteLine(driveInfo.AvailableFreeSpace);
Console.WriteLine(driveInfo.TotalFreeSpace);
Console.WriteLine(driveInfo.TotalSize);
Console.WriteLine(driveInfo.DriveFormat);
Console.WriteLine(driveInfo.DriveType);
}
}
Output
The following is the output −
D: NTFS 76767677788 76767677788 45463434799 NTFS Fixed
Note − The output may vary with different Operating Systems.
Advertisements