Einzelnen Beitrag anzeigen

Benutzerbild von seim
seim

Registriert seit: 11. Nov 2007
83 Beiträge
 
#10

Re: Inhalt eines Ordners auslesen

  Alt 31. Mär 2009, 14:02
Delphi-Quellcode:
function ReadDir(Path, Mask: string; ShowDir, ShowFiles, ShowPath: boolean): TStringlist;
var SRec: TSearchRec;
    DateiListe: TStringList;
begin
  DateiListe := TStringList.Create;

  if Path[length(Path)] <> '\then
    Path:=Path+'\';

  if ShowDir AND Showfiles then
    FindFirst(Path + Mask, faAnyFile, SRec)
  else if ShowFiles then
    FindFirst(Path + Mask, not faDirectory, SRec)
  else if ShowDir then
    FindFirst(Path + Mask, faDirectory, SRec);

  if (SRec.Name <> '.') AND (SRec.Name <> '..') AND (SRec.Name <> '') then
  begin
    if ShowPath then
      DateiListe.Add(Path + SRec.Name)
    else
      DateiListe.Add(SRec.Name);
  end;
  while FindNext(SRec) = 0 do
  begin
    if (SRec.Name <> '.') AND (SRec.Name <> '..') AND (SRec.Name <> '') then
    begin
      if ShowPath then
        DateiListe.Add(Path + SRec.Name)
      else
        DateiListe.Add(SRec.Name);
    end;
  end;
  FindClose(SRec);
  Result := DateiListe;
end;
Allerdings nicht Rekursiv.. wenn du das selbst einbaust kannste ja den Code uppen

VerzInhalt:= ReadDir(dir,'*.*',false,true,true);
  Mit Zitat antworten Zitat