I have a function that searches through folders recursively. I pass in an arraylist of strings to use as a file filter.
For some reason, no matter how many extensions I pass in, only files that are found with the first extension are added.
May I please have some help to fix this code.
Here is my code:
An example of the filters that I pass to this function is:Code:Public Function SearchAndAddToList(ByVal path As String, ByVal Recursive As Boolean, stringArrayListOfFileFilters As ArrayList) If Not Directory.Exists(path) Then Exit Function Dim initDirInfo As New DirectoryInfo(path) Dim tmpListOfAllMedia As MediaItem Dim stringFilenameFilter As String formAddFolder.toolstripStatus.Text = "Retrieving file information from: " & path For Each oFileInfo In initDirInfo.GetFiles Application.DoEvents() For x = 0 To stringArrayListOfFileFilters.Count - 1 stringFilenameFilter = stringArrayListOfFileFilters(x) If oFileInfo.Name Like stringFilenameFilter Then tmpListOfAllMedia.FileInfoObject = oFileInfo tmpListOfAllMedia.MediaObject = MediaPlayerObject.newMedia(oFileInfo.FullName) listOfAllMedia.Add(tmpListOfAllMedia) End If Next Next If Recursive Then For Each oDirInfo In initDirInfo.GetDirectories SearchAndAddToList(oDirInfo.FullName, True, stringArrayListOfFileFilters) Next End If End Function
*.mp3
*.docx
*.txt
In this situation, only *.mp3 files are added to the list.
Example 2:
*.docx
*.mp3
*.txt
In this example, only *.docx files are added.
Why would this be? And more importantly, how can I fix this code?
Thanks




Reply With Quote