Einzelnen Beitrag anzeigen

dominikkv

Registriert seit: 30. Sep 2006
Ort: Gundelfingen
1.109 Beiträge
 
Delphi 2007 Professional
 
#2

Re: Inhalt eines Ordners auslesen

  Alt 23. Okt 2007, 19:11
Delphi-Quellcode:
procedure GetFileList(Path: String; ZielListe: TStringList);
var
  SR: TSearchRec;
begin
  if Path[length(Path)] <> '\then
    Path := Path + '\';
  if FindFirst(Path + '*.*', faAnyFile, SR) = 0 then
    repeat
      if (Lowercase(ExtractFileExt(Path + sr.Name)) = '.jpg') then
        ZielListe.Add(Path + sr.Name);
    until FindNext(SR) <> 0;
  FindClose(SR);
  if FindFirst(Path + '*.*', faAnyFile, SR) = 0 then
    repeat
      if (SR.Attr = faDirectory) and
         (SR.Name <> '.') and (SR.Name <> '..') then
           GetFileList(Path + SR.Name + '\', ZielListe);
    until FindNext(SR) <> 0;
  FindClose(SR);
end;
dabei werden auch unterordner durchsucht.
kannst du so aufrufen:
Delphi-Quellcode:
procedure TForm1.Button1Click;
var
  List: TStringList;
  I: Integer;
begin
  List := TStringList.create;
  try
    GetFileList('<MeinPfad>', List);
    for I := 0 to List.Count do
      LoadMyImage(List[I]); // image laden
  finally
    FreeAndNil(List);
  end;
end;
Dominik
Wer anderen eine Grube gräbt, hat ein Gruben-Grab-Gerät!
  Mit Zitat antworten Zitat