For example: Add file name of all MP3 files in C: / My Music to listbox
procedure TForm1.Button1Click (Sender: TObject); begin CreateDirTree ( 'c: / my music /'); end; procedure TForm1.CreateDirTree (path: string); var SR: TSearchRec; found: integer; begin found: = FindFirst ( PATH '*. *', FAANYFILE, SR; While Found = 0 Do Begin Strtmp: = LowerCase (sr.Name); if Rightstr (StrtMP, 4) = '. MP3' TEN BEGIN ListBox1.Items.Add (Path Sr.name); Createdirtree (Path Sr.Name '/'); end; found: = findnext (sr); end; findclose (sr); end; // *********** *********************************************************** *** The following is another method:
Function Findfile: String; Var Rec: tsearchrec; f: integer; begin f: = findfirst (Path '/ *. INI, REC); while f = 0 do begin if rec.attr = 16 THEN FINDFILE (Path '/' Rec.name); // When the file is recursively calling Else Begin ... / / Treatment End; f: = FindNext (REC); end; FindClose (REC); END; ;