Get System Drives Information in C
Get System Drives Information in C
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"