0% found this document useful (0 votes)
28 views2 pages

Get System Drives Information in C

The DriveInfo class in .NET Framework provides properties and methods to retrieve information about system drives, including the drive type, format, total and free space. The document demonstrates how to use DriveInfo to populate a combo box with available drives, and display details of the selected drive such as name, label, type, format, size and free space when a button is clicked.

Uploaded by

Shaik Sha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views2 pages

Get System Drives Information in C

The DriveInfo class in .NET Framework provides properties and methods to retrieve information about system drives, including the drive type, format, total and free space. The document demonstrates how to use DriveInfo to populate a combo box with available drives, and display details of the selected drive such as name, label, type, format, size and free space when a button is clicked.

Uploaded by

Shaik Sha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Get System Drives Information in C# using DriveInfo class

DriveInfo class in .NET Framework is very useful class you can use to get information about the system drives. It has many properties and methods to query drive information such as drive type, drive format, total size or total free space. In the following Tutorial I will show you how to use this class in .NET Windows Application. DriveInfo class in .NET Framework is very useful class you can use to get information about the system drives. It has many properties and methods to query drive information such as drive type, drive format, total size or total free space. In the following Tutorial I will show you how to use this class in .NET Windows Application.

private void Form1_Load(object sender, EventArgs e) { DriveInfo[] drives = DriveInfo.GetDrives(); foreach (DriveInfo drive in drives) {

this.comboBox1.Items.Add(drive.Name); } } private void button1_Click(object sender, EventArgs e) { string driveName = comboBox1.SelectedItem.ToString(); DriveInfo drive = new DriveInfo(driveName); label2.Text label3.Text label4.Text label5.Text label6.Text ; label7.Text = "Free Disk Space: " + (drive.TotalFreeSpace / 1024 / 1024 / 1024) + " GB"; label8.Text = "Drive Ready: " + drive.IsReady.ToString(); } = = = = = "Drive Name: " "Volume Label: "Drive Type: " "Drive Format: "Total Size: " + " + " + drive.Name; + drive.VolumeLabel; drive.DriveType.ToString(); + drive.DriveFormat; (drive.TotalSize/1024/1024/1024) + " GB"

You might also like