1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29:
| procedure DateiSuchen(Pfad:String; Suche:String; Endung:String; Liste: TStrings; Unterverzeichnis: Boolean); var sr:TSearchRec; begin if (Pfad<>'') and (Pfad[Length(Pfad)]<>'\') then Pfad:=Pfad+'\'; if (FindFirst(Pfad + Suche + Endung, faAnyFile-faDirectory, sr)=0) then begin repeat if (sr.Name<>'.') and (sr.Name<>'..') and (sr.Attr<>faDirectory) then Liste.Add(Pfad+sr.Name) until FindNext(sr)<>0; FindClose(sr); end; if Unterverzeichnis then if (FindFirst(Pfad + '*.*', faDirectory, sr)=0) then begin repeat if (sr.Name<>'.') and (sr.Name<>'..') then DateiSuchen(Pfad + sr.Name, Suche, Endung, Liste, True); until FindNext(sr)<>0; FindClose(sr); end; end;
procedure TForm1.Button1Click(Sender: TObject); begin Listbox1.Clear; DateiSuchen(ShellTreeView1.Path, '\*' + Edit1.Text, '*.txt*', ListBox1.Items, True); end; |