Here I have a function that imports files from a folder and puts them into an array. The problem is: the files from the subfolders aren't included. Can someone plz help me fixing this?
Public Function GetFilesByExtensions(ByVal strPath As String, ByVal colExtensions() As String) As IO.FileInfo()
Dim tmpCollection As New Collection
For Each strExtension As String In colExtensions
For Each aFile As IO.FileInfo In New IO.DirectoryInfo(strPath).GetFiles(strExtension)
tmpCollection.Add(aFile)
Next
Next
Dim tmpFiles(tmpCollection.Count - 1) As IO.FileInfo, i As Integer = 0
For Each aFile As IO.FileInfo In tmpCollection
tmpFiles(i) = aFile
i += 1
Next
Return tmpFiles
End Function
Public Function GetFilesByExtensions(ByVal strPath As String, ByVal colExtensions() As String) As IO.FileInfo()
Dim tmpCollection As New Collection
For Each strExtension As String In colExtensions
For Each aFile As IO.FileInfo In New IO.DirectoryInfo(strPath).GetFiles(strExtension)
tmpCollection.Add(aFile)
Next
Next
Dim tmpFiles(tmpCollection.Count - 1) As IO.FileInfo, i As Integer = 0
For Each aFile As IO.FileInfo In tmpCollection
tmpFiles(i) = aFile
i += 1
Next
Return tmpFiles
End Function