I am trying to populate a combobox with a list of filenames from a selected directory. I am getting the directory OK but the combobox instead of having a list of 8 files max shown when I select the combobox has a full list of all the files selected from that directory.
Code:Private Sub BrowseButton_Click(sender As System.Object, e As System.EventArgs) Handles BrowseButton.Click If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then TextBox1.Text = FolderBrowserDialog1.SelectedPath End If Dim BackupFolder As String = TextBox1.Text For Each BackupFiles As String In My.Computer.FileSystem.GetFiles(BackupFolder, FileIO.SearchOption.SearchTopLevelOnly, "PigginGifts*.bak") ComboBox1.Items.Add(IO.Path.GetFileName(BackupFiles)) Next End Sub




Reply With Quote