Board index » delphi » Copy binary files.. D3

Copy binary files.. D3

For Delhi1.0, use streams:

Source := TFileStream.Create(SourcefileName, fmOpenRead);
Target := TFileStream.Create(TargetFileName, fmCreate);
Target.CopyFrom(Source, Source.size);



Re:Copy binary files.. D3

Mariano Dominguez Molina wrote:
> but How can I copy a file like MSdos copy <src> <dest>?

> I know i can open a file , read a bye write to other etc.

> While not(eof(File)) do
> begin
>         read(file,byte);
>         write(file,byte);
> end;

> but this is a slow and non-secure process (the destiny archive cold be
> corrupted)

> I'd Like to use de windows API to this, but there is not a CopyFile.

But how *else* can you copy a file? I'm pretty sure there is an API call
to do this, but under the covers it will be doing the same thing as your
code. The only differences will be that it will read and write many
bytes at a time, and that it will (presumably) prevent other processes
from modifying the file until it has finished. (Look up file-sharing in
the Help)


Re:Copy binary files.. D3

If you are using Delphi 3 then look in:


It has file copy, move, execute and some more.

James Armstrong

Other Threads