VB.net - Поиск файлов без рекурсии
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x As List(Of String) = Search("G:\Itunes", "*.jpg")
End Sub
Private Function Search(ByVal path As String, ByVal mask As String) As List(Of String)
Dim b As New List(Of String)
Dim a As New List(Of String)
Dim log As Integer = 0
b.AddRange(IO.Directory.GetFiles(path, mask))
a.AddRange(IO.Directory.GetDirectories(path))
Do While a.Count <> 0
'Application.DoEvents()
'Me.Text = a.Count
Try
b.AddRange(IO.Directory.GetFiles(a(0), mask))
Catch
log += 1
End Try
Try
a.AddRange(IO.Directory.GetDirectories(a(0)))
Catch
log += 1
End Try
a.RemoveAt(0)
Loop
Return b
End Function