wyszukiwanie plikow (+podkatalogi)

0

Jak wszyuac wszystkie pliki w dany katalogu oraz we wszystkich podkatalogach?

0

Bylo dosyc niedawno,skorzystaj z szukarki
dopraw to helpem (F1) i juz masz odpowiedz..

procedure TMainFrm.SzukajClick(Sender: TObject);
begin
ListBox1.Clear;
FileSearch(Edit1.Text,Edit2.Text, CheckBox1.State in [cbChecked]);
end;


procedure TMainFrm.FileSearch(const PathName, FileName : string; const InDir : boolean);
var Rec : TSearchRec; 
 Path, CurFile, AllFiles : string; 
 i: integer; 
begin
Path := IncludeTrailingBackslash(PathName);
AllFiles:=FileName;
while AllFiles<>'' do begin
i:=pos(';', AllFiles); 
if i=0 then begin 
  CurFile:=Trim(AllFiles); 
  AllFiles:=''; 
end else begin 
  CurFile:=Trim(Copy(AllFiles, 1, i-1)); 
  Delete(AllFiles, 1, i); 
end; 
if FindFirst(Path + CurFile, faAnyFile - faDirectory, Rec) = 0 then 
try 
  repeat 
   ListBox1.Items.Add(Path + Rec.name); 
  until FindNext(Rec) <> 0; 
finally 
  FindClose(Rec); 
end; 
end; 

if not InDir then Exit; 

if FindFirst(Path + '*.*', faDirectory, Rec) = 0 then 
try 
repeat 
if { (Rec.Attr and faDirectory) and } (Rec.name <> '.') and (Rec.name <> '..') then 
  FileSearch(Path + Rec.name, FileName, True); 
until FindNext(Rec) <> 0; 
finally 
FindClose(Rec); 
end; 
end; // procedure FileSearch - .  

Edit1 - sciezka
Edit2 - maska

Przerob wedle potrzeb..

1 użytkowników online, w tym zalogowanych: 0, gości: 1