Previous Topic: FindClose - Close a Find OperationNext Topic: FindFirstFile - Search for Files in a Directory


FindFirst - Return the Name of the First File in the Search

Valid on NetWare, Symbian OS, UNIX, Windows and Windows CE

The FindFirst function returns the name of the first file that matches a specified filter.

This file content function has the format:

FindFirst(Filter as string, Attrib as integer) as string
FindFirst(Filter as string) as string
Filter

Specifies the files to include in the scan. This parameter can contain a drive specification, a path, and a file name for the files to be found. The file name can contain wildcard characters (? or *).

Attrib

Specifies the file attribute for selecting eligible files in the scan. If the Attrib parameter is omitted, FA_ALLFILES is assumed. Attrib can be selected by ORing the following values:

FA_NONE

Normal file, no attributes

FA_RDONLY

Read-only files

FA_HIDDEN

Hidden files

FA_SYSTEM

System files

FA_LABEL

Volume label

FA_DIR

Directory

FA_ARCHIVE

Archive files

FA_ALLFILES

All files

FA_ANYFILE

Any file

On successful completion, the FindFirst function returns a string containing the file name of the first matching file. Otherwise, it returns an empty string.

Example: FindFirst function

This example finds and lists all files with the .bat extension in the root directory of the C: drive.

Dim Filename as string

Filename=FindFirst("C:\*.BAT",FA_ANYFILE)
while Filename<>""
	 print Filename
	 Filename=FindNext()
wend