Wie kann ich ein Verzeichnis incl. Inhalt(Unterverzeichnisse, Dateien) unter Delphi kopieren?
Wie kann ich ein Verzeichnis incl.
Inhalt(Unterverzeichnisse, Dateien) unter
Delphi kopieren?
Du könntest die SHFileOperation-Proc der Shel API benutzen. Dann wird auch noch bei längeren Kopiervorgängen die Windows „Copy File“ Animation angezeigt.
The following example demonstrates using the SHFileOperation
function to copy a group of files and display a progress dialog. You
can also use the following flags to delete, move and rename a
group of files.
TO_COPY
FO_DELETE
FO_MOVE
FO_RENAME
Note: The buffer that contains the file names to copy must
end with a double null terminating character;
Example:
uses ShellAPI;
procedure TForm1.Button1Click(Sender: TObject);
var
Fo : TSHFileOpStruct;
buffer : array[0…4096] of char;
p : pchar;
begin
FillChar(Buffer, sizeof(Buffer), #0);
p := @buffer;
p := StrECopy(p, ‚C:\DownLoad\1.ZIP‘) + 1;
p := StrECopy(p, ‚C:\DownLoad\2.ZIP‘) + 1;
p := StrECopy(p, ‚C:\DownLoad\3.ZIP‘) + 1;
StrECopy(p, ‚C:\DownLoad\4.ZIP‘);
FillChar(Fo, sizeof(Fo), #0);
Fo.Wnd := Handle;
Fo.wFunc := FO_COPY;
Fo.pFrom := @Buffer;
Fo.pTo := ‚D:‘;
Fo.fFlags := 0;
if ((SHFileOperation(Fo) 0) or
(Fo.fAnyOperationsAborted false)) then
ShowMessage(‚Cancelled‘)
end;