Anzahl der Dateien in einem Ordner
Verfasst: 04.11.2018 20:20
Hallo,
Wie finde ich die Anzahl der Dateien in einem Ordner?
Gruß
Wie finde ich die Anzahl der Dateien in einem Ordner?
Gruß
Das deutsche PureBasic-Forum
https://www.purebasic.fr/german/
Code: Alles auswählen
InitialPath$ = "C:\"
Directory$ = PathRequester("Bitte wählen Sie einen Pfad aus", InitialPath$)
Procedure.i CountFiles (sPath.s)
Protected numFiles = 0
Protected handle
If Right(sPath, 1) <> "\"
sPath + "\"
EndIf
handle = ExamineDirectory(#PB_Any, sPath, "*.*")
If handle = 0
ProcedureReturn 0
EndIf
While NextDirectoryEntry(handle)
If DirectoryEntryType(handle) = #PB_DirectoryEntry_File
numFiles + 1
Else
If DirectoryEntryName(handle) <> "." And DirectoryEntryName(handle) <> ".."
numFiles + CountFiles(sPath + DirectoryEntryName(handle))
EndIf
EndIf
Wend
FinishDirectory(handle)
ProcedureReturn numFiles
EndProcedure
Debug CountFiles(Directory$)