ExamineDirectory()
Syntax
Result = ExamineDirectory(#Directory, DirectoryName$, Pattern$)Description
Start to examine a directory for listing with the functions NextDirectoryEntry(), DirectoryEntryName() and DirectoryEntryType().
Parameters
#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).
Please be aware of a MS Windows specific behaviour: When using a 3-char file name extension any extension starting with those 3 chars will match, e.g. "*.log" will also match a file name/extension "test.log_1".
Return value
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.
Remarks
Once the enumeration is done, FinishDirectory() must be called to free the resources associated to the listing.
Specific OS path separator characters are available #PS, #NPS, #PS$ ('\') and #NPS$ ('/').
Example
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
See Also
FinishDirectory(), NextDirectoryEntry(), DirectoryEntryType(), DirectoryEntryName(), DirectoryEntrySize(), DirectoryEntryAttributes(), DirectoryEntryDate()
Supported OS
All