Function Reference

FileFindFirstFile

Returns a filename according to search string.

FileFindFirstFile ( "filename" )

 

Parameters

filename File search string. (* and ? wildcards accepted)

 

Return Value

Success: Returns a search "handle" or use with subsequent FileFindNextFile functions.
Failure: Returns -1 if error occurs.

 

Remarks

The search string is not case sensitive.
Wildcards: In general, * denotes zero or more characters, and ? denotes zero or one character. If your file search string contains only wildcards (or is "*.*"), then see the example below for the return value!

When you have finished searching with the FileFind... functions you must call FileClose() to release the search handle.

 

Related

FileClose, FileFindNextFile

 

Example


; Shows the filenames of all files in the current directory, note that "." and ".." are returned.
$search = FileFindFirstFile("*.*")  

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
   
    MsgBox(4096, "File:", $file)
WEnd

; Close the search handle
FileClose($search)