[Overview][Constants][Types][Procedures and functions][Variables] Reference for unit 'Dos' (#rtl)

FindFirst

Start search for one or more files.

Declaration

Source position: dosh.inc line 109

procedure FindFirst(

  const path: PathStr;

  attr: Word;

  var f: SearchRec

);

Description

FindFirstsearches the file specified in Path. Normal files, as well as all special files which have the attributes specified in Attrwill be returned.

It returns a SearchRecrecord for further searching in F. Pathcan contain the wildcard characters ?(matches any single character) and *(matches 0 ore more arbitrary characters). In this case FindFirstwill return the first file which matches the specified criteria. If DosErroris different from zero, no file(s) matching the criteria was(were) found.

Remark: On os/2, you cannot issue two different FindFirstcalls. That is, you must close any previous search operation with FindClosebefore starting a new one. Failure to do so will end in a Run-Time Error 6 (Invalid file handle)

Errors

Errors are reported in DosError.

See also

FindNext

  

Find next matching file after FindFirst

FindClose

  

Dispose resources allocated by a FindFirst/FindNextsequence.

Example

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.