private void Button8_Click(object sender, EventArgs e) { comboBox2.Items.Clear(); Drive = null; Drives = Device.GetDrives(); if (Drives == null) { return; } if (Drives.Length == 0) { return; } foreach (MediaDriveInfo d in Drives) { comboBox2.Items.Add(d.VolumeLabel); } }
private void Button2_Click(object sender, EventArgs e) { if (Device == null) { Device = Devices.ElementAt(comboBox1.SelectedIndex); Device.Connect(); Device.DeviceRemoved += Device_DeviceRemoved; button2.Text = "Disconnect"; Drives = Device.GetDrives(); foreach (MediaDriveInfo d in Drives) { comboBox2.Items.Add(d.VolumeLabel); } } else if (Device.IsConnected) { Device.Disconnect(); Device = null; button2.Text = "Connect"; Drive = null; Drives = null; comboBox2.Items.Clear(); } else { Device = Devices.ElementAt(comboBox1.SelectedIndex); Device.Connect(); Device.DeviceRemoved += Device_DeviceRemoved; button2.Text = "Disconnect"; Drives = Device.GetDrives(); if (Drives == null) { return; } if (Drives.Length == 0) { return; } foreach (MediaDriveInfo d in Drives) { comboBox2.Items.Add(d.VolumeLabel); } } }
}//all private void ComboBox2_SelectedIndexChanged(object sender, EventArgs e) { Drive = Drives[comboBox2.SelectedIndex]; }