Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Delphi: How to copy a whole directory ?

730 views
Skip to first unread message

David

unread,
Aug 10, 2004, 7:53:20 AM8/10/04
to
i know how to delete the whole directory , how about copy the whole
directory ?

Thanks for help.


Rob Kennedy

unread,
Aug 10, 2004, 9:45:36 AM8/10/04
to
David wrote:
> i know how to delete the whole directory , how about copy the whole
> directory ?

For both those operations, I would use the ShFileOperation API function.
It's documented on MSDN, and there are many examples on the Web and in
the newsgroup archives.

--
Rob

Slava Antonov

unread,
Aug 10, 2004, 11:31:15 AM8/10/04
to
Hello David, you wrote:

> i know how to delete the whole directory , how about copy the whole
> directory ?

SHFileOperation

--
With best regards, Slava
http://slava.users.otts.ru

Charles Hacker

unread,
Aug 10, 2004, 8:41:46 PM8/10/04
to
David wrote:
>
> i know how to delete the whole directory , how about copy the whole
> directory ?

USES ShellAPI;

function TForm1.CopyFileOrFolder(Source, Destination : string) :
Boolean;
var
SHFileOp : TSHFileOpStruct;
Error : Integer;
Aborted : Boolean;
begin
FillChar(SHFileOp,SizeOf(SHFileOp),0);
SHFileOp.Wnd:= Handle;
SHFileOp.wFunc:= FO_COPY;
SHFileOp.pFrom:= PChar(Source + #0);
SHFileOp.pTo:= PChar(Destination +#0);
SHFileOp.fFlags:= FOF_ALLOWUNDO;
//fFlags := FOF_ALLOWUNO or FOF_SIMPLEPROGRESS;
Error:= SHFileOperation(SHFileOp);
Aborted:= (Error = 117);
if Aborted then Error:= 0;
Result:= (Error = 0) and not Aborted;
end;

--
Charles Hacker
Lecturer in Electronics and Computing
School of Engineering
Griffith University - Gold Coast
Australia

David

unread,
Aug 11, 2004, 3:11:20 AM8/11/04
to
thanks all :)

"David" <da...@fd.com> 撰寫於郵件新聞
:4118b730$1...@newsgroups.borland.com...

0 new messages