### Find Files recursive

To find files from a folder including subfolders, the File.ListFiles subroutine is executed resursively.
The files found are added to a global List.
' Find files in a folder resursive
' Parameter Path to find files from
' Returns List of files in a global var FFileList As List (must initialized)
' Example usage:
' Dim dir As String = File.DirApp
' FFileList.Clear
' FindFiles(dir)
' listviewFiles.Items.AddAll(FFileList)
`Sub FindFiles(Path As String)
Dim FileList, FolderList As List
Dim FileFound As String
FileList.Initialize
FolderList.Initialize
If Path = "" Then Path = File.DirApp
If File.IsDirectory(Path,"") Then
Try
FileList = File.ListFiles(Path)
If FileList.IsInitialized Then
If FileList.Size > 0 Then
FileFound = Path
FFileList.Add(FileFound)
For i = 0 To FileList.Size - 1
FileFound = FileList.Get(i)
If File.IsDirectory(Path & "/" & FileFound,"") Then
FolderList.Add(Path & "/" & FileFound)
Else
FFileList.Add(Path & "/" & FileFound)
End If
Next
End If
End If
Catch
Log(LastException & " " & Path & " " & FileList.Size & " (File)")
End Try
'Recursive search for files
Try
If FolderList.IsInitialized Then
If FolderList.Size > 0 Then
For i = 0 To FolderList.Size - 1
FileFound = FolderList.Get(i)
FindFiles(FileFound)
Next
End If
End If
Catch
Log(LastException & " " & FolderList.Size & " " & FileFound & " (Folder)")
End Try
End If
End Sub`

Changed: , Category: Files, File: T6C193M1376.htm, ID: 1376