Result = ExamineDirectory(#Directory, DirectoryName$, Pattern$)Description
Start to examine a directory for listing with the functions NextDirectoryEntry(), DirectoryEntryName() and DirectoryEntryType().
#Directory A number to identify the new directory listing. #PB_Any can be used as a parameter to auto-generate this number. DirectoryName$ The directory to examine. Pattern$ A pattern to filter the returned entries by. For example: A 'Pattern$' like "*.*" or "" will list all the files (and sub-directories) in the directory. A 'Pattern$' like "*.exe" will list only .exe files (and sub-directories ending with .exe if any).
Returns nonzero if the directory can be enumerated or zero if there was an error. If #PB_Any was used as the #Directory parameter then the generated directory number is returned.
Once the enumeration is done, FinishDirectory() must be called to free the resources associated to the listing.
Directory$ = GetHomeDirectory() ; Lists all files and folder in the home directory If ExamineDirectory(0, Directory$, "*.*") While NextDirectoryEntry(0) If DirectoryEntryType(0) = #PB_DirectoryEntry_File Type$ = "[File] " Size$ = " (Size: " + DirectoryEntrySize(0) + ")" Else Type$ = "[Directory] " Size$ = "" ; A directory doesn't have a size EndIf Debug Type$ + DirectoryEntryName(0) + Size$ Wend FinishDirectory(0) EndIf
FinishDirectory(), NextDirectoryEntry(), DirectoryEntryType(), DirectoryEntryName(), DirectoryEntrySize(), DirectoryEntryAttributes(), DirectoryEntryDate()