(A) the specified file search function TForm1.findSpecFile (sDirectory, fName: string): boolean; var sr: TSearchRec; begin if FindFirst (sDirectory fName, faAnyFile, sr) = 0 then begin FindClose (sr); result: = true ; end else begin result: = false; end; end; (B) contains the file name lookup procedure TForm1.findLikeFile (sDirectory, likeName: string); var sr: TSearchRec; begin if FindFirst (sDirectory '* *.', faAnyFile, SR) = 0 THEN Begin Repeat if Pos (Likename, LowerCase (sr.name))> 0 Then Begin if (sr.attr and fadirectory) = 0 Then ListBox1.Items.add ('):' sdirectory sr.name Else ListBox1.Items.Add ('directory:' sdirectory sr.name); end; until findnext (sr) <> 0; FindClose (SR); end; end; (1) Finding a specified extension file Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); Var Sr: tsearchrec; begin listbox1.items.clear; if FindFirst ('D: / Work / *. Xls', Faanyfile, SR) = 0 THEN BEGIN REPEAT IF POS ('. Xls ', Lowercase (sr.name))> 0 Then ListBox1.items.add (sr.name); Until FindNext (SR) <> 0; FindClose (SR ); End; end; or procedure tform1.button1click (sender: TOBJECT); Begin ListBox1.Items.clear; Findlikefile ('D: / Work /', 'XLS'); END; (2) Find all of a directory File, non-directory procedure tform1.button2click (sender: Tobject); var sr: tsearchrec; begin listbox1.items.clear; if Findfirst ('D: / Work /*.*', FaanyFile, SR) = 0 THEN BEGIN REPEAT IF (sr.attr and fadirectory) = 0 THEN ListBox1.items.add (sr.name '' INTOSTR (Sr.attr)); Until FindNext (SR) <> 0; FindClose (SR); End; ShowMessage (INTSTR ListBox1.Items.count); end; (3)