Hm, so ganz war es das aber auch nicht:
Delphi-Quellcode:
procedure FindAllFiles(FileList: TStrings; RootFolder: string; Mask: string = '*'; Recurse: Boolean = True;
AddFolderNames: Boolean = False; IgnoreMaskAtFolderNames: Boolean = True);
procedure LFindAllFiles(AParentFolder: string);
var LSearchRec : TSearchRec;
begin
if FindFirst(AParentFolder + '*', faAnyFile, LSearchRec) = 0 then
begin
repeat
if (LSearchRec.Name <> '.') and (LSearchRec.Name <> '..') then
begin
if LSearchRec.Attr and faDirectory = faDirectory then
begin
if AddFolderNames and
(IgnoreMaskAtFolderNames or Like(Mask, AnsiLowerCase(LSearchRec.Name))) then
FileList.AddObject(AParentFolder + LSearchRec.Name, TObject(True));
if Recurse then
//FindAllFiles(FileList, AParentFolder + LSearchRec.Name + '\');
LFindAllFiles(IncludeTrailingPathDelimiter(RootFolder));
end
else if Like(Mask, AnsiLowerCase(LSearchRec.Name)) then
FileList.AddObject(AParentFolder + LSearchRec.Name, TObject(False));
end;
until FindNext(LSearchRec) <> 0;
FindClose(LSearchRec);
end;
end;
begin
Mask := AnsiLowerCase(Mask);
LFindAllFiles(IncludeTrailingPathDelimiter(RootFolder));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
FindAllFiles(ListBox1.Items, 'd:\Dokumente'); //, '*', True, True, True);
end;
Das bringt mir das CPU fenster mit einer AccesViolation. Ich kann leider mit dem CPU fenster nichts anfangen.