GetFiles2
GetFiles2
Returns a collection of strings representing the names of files within a directory.
Syntax
FileSystem.GetFiles2(Directory, SearchOption)
FileSystem.GetFiles2(Directory, SearchOption, Wildcard [, Wildcard...])
Parameters
|
|
Directory |
String, input |
|
|
|
Directory to be searched. |
|
|
SearchOption |
Enumeration, input |
|
|
|
Whether to include subfolders. Default is SearchTopLevelOnly. |
|
|
Wildcard |
String(s), input |
|
|
|
One or more patterns to be matched. |
Remarks
|
|
SearchOption |
|
|
|
SearchOption.SearchAllSubDirectories |
Search the specified directory and all subdirectories within it. Default. |
|
|
SearchOption.SearchTopLevelOnly |
Search only the specified directory and exclude subdirectories. |
|
|
SpecialDirectories |
|
|
|
AllUsersApplicationData |
Gets a path name pointing to the Application Data directory for all users. |
|
|
CurrentUserApplicationData |
Gets a path name pointing to the Application Data directory for the current user. |
|
|
Desktop |
Gets a path name pointing to the Desktop directory. |
|
|
MyDocuments |
Gets a path name pointing to the My Documents directory |
|
|
MyMusic |
Gets a path name pointing to the My Music directory. |
|
|
MyPictures |
Gets a path name pointing to the My Pictures directory. |
|
|
ProgramFiles |
Gets a path name pointing to the Program Files directory. |
|
|
Programs |
Gets a path name pointing to the Programs directory. |
|
|
Temp |
Gets a path name pointing to the Temp directory. |
Example
This example displays only .txt files in the specified directory in a message box:
Sub Main()
For Each foundFile In FileSystem.GetFiles2(SpecialDirectories.MyDocuments, SearchOption.SearchTopLevelOnly, "*.txt")
Msgbox foundFile
Next
End Sub