| csyasar | 30.04.2004 - 15:52:04 |
procedure TForm1.FindFiles(StartDir, FileMask: string);
var SR: TSearchRec; DirList: TStringList; IsFound: Boolean; i: integer; begin if StartDir[length(StartDir)] <> '\' then StartDir := StartDir + '\'; IsFound := FindFirst(StartDir+FileMask, faAnyFile-faDirectory, SR) = 0; while IsFound do begin Memo1.Lines.Add(StartDir + SR.Name); IsFound := FindNext(SR) = 0; end; FindClose(SR); DirList := TStringList.Create; IsFound := FindFirst(StartDir+'*.*', faAnyFile, SR) = 0; while IsFound do begin if ((SR.Attr and faDirectory) <> 0) and (SR.Name[1] <> '.') then DirList.Add(StartDir + SR.Name); IsFound := FindNext(SR) = 0; end; FindClose(SR); for i := 0 to DirList.Count-1 do FindFiles(DirList[i], FileMask); DirList.Free; end; // Kullanımı: FindFiles('C:\windows\', '*.txt'); | |