Returns the names of all files in a specified directory that meet the specified criteria.
object.FindFiles ( PathName [,AttributeFilter] ) |
- PathName
- Required. A String that represents the directory and file filter to search.
- AttributeFilter
- Optional. A Long that specifies one or more file attributes to use to limit the search.
Array
AttributeFilter is a long representing a set of bit flags that can be used to restrict the search to files with particular attributes. Multiple AttributeFilters can be combined using the OR operator. [Optional].
The following AttributeFilter values are supported:
Flag | Description |
---|---|
&H1 | Specifies that only Read Only files should be returned. |
&H2 | Specifies that only Hidden files should be returned. |
&H4 | Specifies that only System files should be returned. |
&H10 | Specifies that only Directories should be returned. |
&H20 | Specifies that only Archive files should be returned. |
&H80 | Specifies that only Normal files should be returned. This is the default. |
&H100 | Specifies that only Temporary files should be returned. |
&H800 | Specifies that only Compressed files should be returned. |
Displays a message box with the name of each file that matches the input criteria.
FindFiles Example (VBScript) | Copy Code |
---|---|
Sub FindFiles Dim pFile, arrFileNames, strCurrFileName Set pFile = Application.CreateAppObject("File") arrFileNames = pFile.FindFiles("C:\TEMP\*.txt") For Each strCurrFileName in arrFileNames MsgBox strCurrFileName Next End Sub |