@vera
Try this revised version. I snipped the original code and missed a variable definition. "Count" must be a static or global variable.
Code: Select all
Global Msg$
Procedure RecursivelyExploreDirectory(SourceDirectory$, Start, Pattern$)
Static Count ; must be a static or global variable
If ExamineDirectory(Start, SourceDirectory$, "*.*")
While NextDirectoryEntry(Start)
Select DirectoryEntryType(Start)
Case #PB_DirectoryEntry_Directory
If DirectoryEntryName(Start) <> "." And DirectoryEntryName(Start) <> ".."
a$ = SourceDirectory$+DirectoryEntryName(Start)+"\"
Start+1
RecursivelyExploreDirectory(a$, Start, Pattern$)
ExplorerListGadget(0, 0, 0, 0, 0, a$ + pattern$, #PB_Explorer_NoFolders | #PB_Explorer_NoParentFolder)
Start-1
EndIf
EndSelect
Wend
FinishDirectory(Start)
ExplorerListGadget(0, 0, 0, 0, 0, SourceDirectory$ + Pattern$, #PB_Explorer_NoFolders | #PB_Explorer_NoParentFolder)
;Do whatever you need to with the contents resulting explorer file list
If CountGadgetItems(0) > 0
Count + CountGadgetItems(0) ; increase selected file count
; Optionally, report folder results in a message
Msg$ + SourceDirectory$ + ": " + Str(CountGadgetItems(0)) + " in folder" + " - " + Str(count) + " total files" + #LF$
; Optionally, add each selected file to external list
For K = 0 To CountGadgetItems(0)-1
AddGadgetItem(2,-1,SourceDirectory$ + GetGadgetItemText(0,k,0))
Next
EndIf
EndIf
ProcedureReturn Count
EndProcedure
SetCurrentDirectory("C:\folder\")
If OpenWindow(0, 0, 0, 400, 200, "Recursive Explorer List", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListViewGadget(2,10,10,380,180) ; results list if desired
Starttime = ElapsedMilliseconds() ; timer start
Files.l = RecursivelyExploreDirectory(GetCurrentDirectory(),1,"*.exe;*.dll")
Totaltime = ElapsedMilliseconds() - Starttime ; capture operation time
; Optionally, build a report message
Msg$ + #LF$ + Str(Files) + " files selected from target folder" + #LF$
Msg$ + Str(CountGadgetItems(2)) + " listed" + #LF$
Msg$ + Str(Totaltime) + " ms"
MessageRequester("Find Files", Msg$ , #MB_ICONINFORMATION)
; end optional report message
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
End