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

File Copy

35 views
Skip to first unread message

A. Scholberg

unread,
Dec 26, 2000, 5:14:15 AM12/26/00
to
Although I do find file delete, rename, fileexists and many other file
management functions/procedures, I do not seem able to find a simple
fileCopy.

Can anyone direct me to this function?

Thanks,
André


Thomas

unread,
Dec 26, 2000, 6:49:32 AM12/26/00
to
The CopyFile function copies an existing file to a new file.

BOOL CopyFile(

LPCTSTR lpExistingFileName, // pointer to name of an existing file
LPCTSTR lpNewFileName, // pointer to filename to copy to
BOOL bFailIfExists // flag for operation if file exists
);

tom

A. Scholberg <scho...@bluewin.ch> schrieb in im Newsbeitrag:
3A486F77...@bluewin.ch...

Ralph Friedman (TeamB)

unread,
Dec 26, 2000, 7:34:26 AM12/26/00
to
A. Scholberg,

in message <3A486F77...@bluewin.ch> you wrote:
> Although I do find file delete, rename, fileexists and many other file
> management functions/procedures, I do not seem able to find a simple
> fileCopy.
>

Use either the CopyFile API or ShFileOperation (in ShellAPI).
--
Regards
Ralph (TeamB)
===

Mark Miller

unread,
Dec 26, 2000, 4:23:36 PM12/26/00
to
A example in Delphi for this is:

CopyFile( pchar(myFileNameVar), pchar( destFileNamePathVar), false);

Copies the file myFileNameVar to destFileNamePathVar and does not fail if
the file already exists, instead it is overwritten.

Also, there is a Delphi utility unit in the examples that has a Dlephi
CopyFile(..) method. You can find it in:

..\Borland\Delphi5\Demos\Doc\Filmanex\fmxUtils.pas
I kind of remember something buggy about the fmxUtils.CopyFile(..) routine,
but I can't remember what it is. I've been using the Windows.CopyFile(..)
for so long I've forgotten. It's just as easy. :)


"Thomas" <Thom...@gmx.ch> wrote in message
news:92a03d$jb...@bornews.inprise.com...

A. Scholberg

unread,
Dec 26, 2000, 5:26:33 PM12/26/00
to
Thanks to all. This does solve my problem.

I do wish however that our Delphi doc were more self contained...

André

Ronald Hoek

unread,
Dec 27, 2000, 8:11:29 AM12/27/00
to
For advanced usage you could use streams...

FS1, FS2: TFileStream;

begin
try
FS1:= TFileStream.Create(FromFile,fmRead or fmShareDenyNone); //
"fmShareDenyWrite" to be sure someone doesn't write to the file while your
copying it
FS2:= TFileStream.Create(ToFile,fmCreate or fmShareExclusive);
FS2.CopyFrom(FS1,0);
finally
if assigned(FS1) then FS1.Free;
if assigned(FS2) then FS2.Free;
end;
end;

--
Greatings,

Ronald Hoek

Applicationdevelopper
ComponentAgro B.V.
Barendrecht

Phone. +31-180-621306
Fax. +31-180-611797

mailto:ho...@componentagro.nl
http://www.componentagro.nl

A. Scholberg <scho...@bluewin.ch> schreef in berichtnieuws
3A486F77...@bluewin.ch...

0 new messages