Thema: Delphi Dateinamen auslesen

Einzelnen Beitrag anzeigen

C.Schoch

Registriert seit: 2. Jan 2006
Ort: Wüstenrot
235 Beiträge
 
Turbo Delphi für Win32
 
#7

Re: Dateinamen auslesen

  Alt 13. Apr 2006, 20:23
Hi
Ich machs damit kann auch Unterordner, ist aber nicht von mir
Delphi-Quellcode:
///////////////////////////GetFiles////////////////////////////////////
// Autor: Daniel B
//////////////////////////////////////////////////////////////////////////
procedure TForm1.GetFiles(const Directory: string; Files: TStrings;
const FileMask: string = '*.*'; const SubFolders: Boolean = True);

  function SlashSep(const Path, S: string): string;
  begin
    if AnsiLastChar(Path)^ <> '\then
      Result := Path + '\' + S
    else
      Result := Path + S;
  end;

var
  SearchRec: TSearchRec;
begin
  if FindFirst(SlashSep(Directory, FileMask),
    faAnyFile - faDirectory - faVolumeID, SearchRec) = 0 then
  begin
    try
      repeat
        Files.Add(SlashSep(Directory, SearchRec.Name) + ' -- ' +
          DateTimeToStr(FileDateToDateTime(FileAge(SlashSep(
            Directory, SearchRec.Name)))));
      until
        FindNext(SearchRec) <> 0;
    finally
      SysUtils.FindClose(SearchRec);
  end;
end;

  if SubFolders then
  begin
    if FindFirst(SlashSep(Directory,'*.*'), faAnyFile, SearchRec) = 0 then
    begin
      try
        repeat
          if (SearchRec.Attr and faDirectory) <> 0 then
          begin
            if ((SearchRec.Name <> '.') and (SearchRec.Name <> '..')) then
              GetFiles(SlashSep(Directory, SearchRec.Name), Files, FileMask, SubFolders);
          end;
        until
          FindNext(SearchRec) <> 0;
      finally
        SysUtils.FindClose(SearchRec);
      end;
    end;
  end;
end;
Tschau Christian
Das System hofft auf Besserung
[Siemens]
  Mit Zitat antworten Zitat