Einzelnen Beitrag anzeigen

Benutzerbild von s.h.a.r.k
s.h.a.r.k

Registriert seit: 26. Mai 2004
3.159 Beiträge
 
#4

Re: Ordnerinhalt kopieren

  Alt 11. Nov 2005, 20:30
Also wir man einen Ordnerinhalt ausliest ist eigentlich ganz einfach:

Delphi-Quellcode:
procedure GetFilesInDirectory(Directory: String; const Mask: String;
                              List: TStrings;
                              WithSubDirs, ClearList: Boolean);
  procedure ScanDir(const Directory: String);
  var
    SR: TSearchRec;
  begin
    if FindFirst(Directory + Mask, faAnyFile - faDirectory, SR) = 0 then try
      repeat
        List.Add(Directory + SR.Name)
      until FindNext(SR) <> 0;
    finally
      FindClose(SR);
    end;

    if WithSubDirs then begin
      if FindFirst(Directory + '*.*', faAnyFile, SR) = 0 then try
        repeat
          if (SR.Attr = faDirectory) and
             (SR.Name <> '.') and (SR.Name <> '..') then
            ScanDir(Directory + SR.Name + '\');
        until FindNext(SR) <> 0;
      finally
        FindClose(SR);
      end;
    end;
  end;

begin
  List.BeginUpdate;
  try
    if ClearList then
      List.Clear;
    if Directory = 'then Exit;
    if Directory[Length(Directory)] <> '\then
      Directory := Directory + '\';
    ScanDir(Directory);
  finally
    List.EndUpdate;
  end;
end;
Die StringList musst halt dann noch im TreeView ausgeben.

Diese List musst du halt noch zwischenspeichern und mit dem Befehl CopyFile dann in ein bestimmtes Verzeichnis kopieren.

mfg shark
»Remember, the future maintainer is the person you should be writing code for, not the compiler.« (Nick Hodges)
  Mit Zitat antworten Zitat