Hello,
I have to rewrite a program that I previously made in VB6 in VB.Net 2005. I would like to have a combobox with only the available optical (CD/DVD) drives listed. How is this done in VB.NET? Any help or direction is greatly appreciated.
Thanks
Printable View
Hello,
I have to rewrite a program that I previously made in VB6 in VB.Net 2005. I would like to have a combobox with only the available optical (CD/DVD) drives listed. How is this done in VB.NET? Any help or direction is greatly appreciated.
Thanks
vb.net Code:
Dim opticalDrives As New List(Of IO.DriveInfo) For Each drive As IO.DriveInfo In IO.DriveInfo.GetDrives() If drive.DriveType = IO.DriveType.CDRom Then opticalDrives.Add(drive) End If Next drive With Me.ComboBox1 .ValueMember = "Name" .DataSource = opticalDrives End With
Thanks jmcilhinney for your help..It works great. One more question. It currently listes the drive letter, is it possible to list the drive letter AND the title of the disc thats in the drive?
The VolumeLabel property of the DriveInfo object returns the disc name. If you want both the letter and the label you'd have to combine them yourself and then add them to the ComboBox.