Registriert seit: 12. Sep 2005
Ort: Hessen
268 Beiträge
|
Re: Alle Ordner und Dateien aus Freigabe auflisten
5. Okt 2006, 15:47
Funktion:
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(AnsiLowerCase(LSearchRec.Name), Mask)) then
FileList.AddObject(AParentFolder + LSearchRec.Name, TObject(True));
if Recurse then
LFindAllFiles(AParentFolder + LSearchRec.Name + '\');
end
else if Like(AnsiLowerCase(LSearchRec.Name), Mask) 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;
Aufruf:
Delphi-Quellcode:
var
Lst: TStrings;
begin
Lst := TStringList.Create;
FindAllFiles(Lst, '\\pc-name\c$', '*', False, True, True);
ShowMessage(Lst.Text);
Lst.Free;
end;
Grüße
n0b0dy
|
|
Zitat
|