Hi.
Yes, it's possible.
In order for this sample to work you need the following:
A new form, with 2 combos, 1 button and 1 checklistbox.
Name the combos cmbDrive and cmbType Set their drop down style to "DropDown". Name the button btnSearch.
Leave the rest "as is".
Then paste this code into the form.
VB Code:
Private Sub Search(ByVal Path As String, ByVal Filter As String) Dim dInfo As IO.DirectoryInfo Dim dInfos() As IO.DirectoryInfo Dim fInfo As IO.FileInfo Dim fInfos() As IO.FileInfo 'Search for files in the current path Try Console.WriteLine("Searchin " & Path) fInfos = New IO.DirectoryInfo(Path).GetFiles(Filter) For Each fInfo In fInfos CheckedListBox1.Items.Add(fInfo.FullName) CheckedListBox1.Refresh() Next Catch End Try 'Search for subdirs in the currentpath Try dInfos = New IO.DirectoryInfo(Path).GetDirectories For Each dInfo In dInfos 'call search again the check for files in the subdir. Me.Search(dInfo.FullName, Filter) Next Catch End Try End Sub Private Sub frmTemp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load cmbDrive.Items.Add("C:\") cmbDrive.Items.Add("D:\") cmbType.Items.Add(".wav") cmbType.Items.Add(".mp3") End Sub Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click CheckedListBox1.Items.Clear() Me.Search(cmbDrive.Text, "*" & cmbType.Text) End Sub




Reply With Quote