[Overview][Constants][Types][Procedures and functions][Variables] | Reference for unit 'Dos' (#rtl) |
Start search for one or more files.
Source position: dosh.inc line 109
procedure FindFirst( |
const path: PathStr; |
attr: Word; |
var f: SearchRec |
); |
FindFirst searches the file specified in Path. Normal files, as well as all special files which have the attributes specified in Attr will be returned.
It returns a SearchRec record for further searching in F. Path can contain the wildcard characters ? (matches any single character) and * (matches 0 ore more arbitrary characters). In this case FindFirst will return the first file which matches the specified criteria. If DosError is different from zero, no file(s) matching the criteria was(were) found.
Remark: | On os/2, you cannot issue two different FindFirst calls. That is, you must close any previous search operation with FindClose before starting a new one. Failure to do so will end in a Run-Time Error 6 (Invalid file handle) |
Errors are reported in DosError.
|
Find next matching file after FindFirst |
|
|
Dispose resources allocated by a FindFirst/FindNext sequence. |
Program Example7; uses Dos; { Program to demonstrate the FindFirst and FindNext function. } var Dir : SearchRec; begin FindFirst('*.*',archive,Dir); WriteLn('FileName'+Space(32),'FileSize':9); while (DosError=0) do begin Writeln(Dir.Name+Space(40-Length(Dir.Name)),Dir.Size:9); FindNext(Dir); end; FindClose(Dir); end.
No notes exist for this page yet.