using System;
using System.Windows.Forms;
using System.IO;

namespace _13_1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DriveInfo drive = new DriveInfo(listBox1.Text);
            //---------------------------------------------------------------
            listBox2.Items.Clear();
            listBox2.Items.Add("Drive Name: " + drive.Name);
            listBox2.Items.Add("Drive Type: " + drive.DriveType);
            listBox2.Items.Add("Is Ready: " + drive.IsReady);
            //---------------------------------------------------------------
            if (drive.IsReady == true)
            {
                listBox2.Items.Add("Drive Format: " + drive.DriveFormat);
                listBox2.Items.Add("Volume Label: " + drive.VolumeLabel);
                listBox2.Items.Add("Available Free Space: " + drive.AvailableFreeSpace);
                listBox2.Items.Add("Total Free Space: " + drive.TotalFreeSpace);
                listBox2.Items.Add("Total Size: " + drive.TotalSize);
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            foreach (DriveInfo drv in DriveInfo.GetDrives())
                if (drv.IsReady == true)
                    listBox1.Items.Add(drv.RootDirectory + ": " + drv.VolumeLabel);
        }
    }
}