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

CopyFile command in Delphi??

360 views
Skip to first unread message

Troy Guillory

unread,
May 14, 1996, 3:00:00 AM5/14/96
to

Greetings:

I am looking for an easy way to copy files through Delphi. I am
writing a simple copy program that takes all the files off a number
of disks and dumps them to a destination directory. If anyone has any
suggestions I would appreciate some mail.
Thanks.

-------------------------------------------------------------
Troy M. Guillory Keep Smilin'
University of Colorado Boulder \\///
Computer Science (o o)
guil...@cs.colorado.edu -----ooO-(_)-Ooo----

Daniel Salo

unread,
May 14, 1996, 3:00:00 AM5/14/96
to

Include the LZExpand unit and try LZCopy. The LZ family of functions
are native WIN API's.

Dan.


On 14 May 1996 04:28:00 GMT, guil...@tigger.cs.colorado.edu (Troy

Bob Mandel

unread,
May 14, 1996, 3:00:00 AM5/14/96
to ds...@shore.net

Some additional input plus a bothersome bug:

Here is a snippet of code I use to perform copies in Delphi -

while i < ListBox1.Items.Count do begin
StrPCopy(SrcChar,ListBox1.Items[i]);
SrcFile := LZOpenFile(SrcChar,OpenBuf,of_Share_Deny_Write or
of_Read);
CopyFile := FileCreate(aNewDir + CopyList[i]);
LZCopy(SrcFile,CopyFile);
FileClose(SrcFile);
FileClose(CopyFile);
i := i + 1;
end;

where ListBox1 contains a list of file to be copied and aNewDir is the
destination directory to copy them to. SrcChar is declared PChar and
OpenBuf is declared TOFStruct as per Win API documentation.

What happens to when I run this is that about 15 out of 60 files
actually get copied, the rest get created but end up with size of zero.
I've run into this kind of limitation in several scenarios, but I'm
hoping to find a way around it...

Can you duplicate this error? And if not, what are you doing differently
- I am running Delphi 2.0 on NT 3.51 if that helps. Thanks in advance
for any ideas or advice...


\\\\\\\\\\\\\\\\\\
\\ Bob Mandel
\\ KPCo GIS Group
\\\\\\\\\\\\\\\\\\

Chad Z. Hower

unread,
May 15, 1996, 3:00:00 AM5/15/96
to

Bob Mandel wrote:
>
> Here is a snippet of code I use to perform copies in Delphi -
>
> while i < ListBox1.Items.Count do begin
> StrPCopy(SrcChar,ListBox1.Items[i]);

This is from the DELPHI HELP FILE..... (Slightly modified)

procedure FileCopy(const sFrom, sTo: String);
var
FromF, ToF: file;
NumRead, NumWritten: Integer;
Buf: array[1..2048] of Char;
begin
AssignFile(FromF, sFrom);
Reset(FromF, 1); { Record size = 1 }
try
AssignFile(ToF, sTo);
Rewrite(ToF, 1); { Record size = 1 }
try
repeat
BlockRead(FromF, Buf, SizeOf(Buf), NumRead);
BlockWrite(ToF, Buf, NumRead, NumWritten);
until (NumRead = 0) or (NumWritten <> NumRead);
finally System.CloseFile(FromF); end;
finally System.CloseFile(ToF); end;
end;

Paul Whittington

unread,
May 16, 1996, 3:00:00 AM5/16/96
to

I recently wrote a file copy procedure and used the Win32 API function
"CopyFile", I think it was "CopyFile" anyway I don't have the source
with me here at work, it was very simple practically a no-brainer.

Chad Z. Hower wrote:
> ... This is from the DELPHI HELP FILE..... (Slightly modified)
>
> procedure FileCopy(const sFrom, sTo: String); ...

Chad Z. Hower

unread,
May 16, 1996, 3:00:00 AM5/16/96
to

Yes, if your in 32. This procedure is good for 16 too.

Gregg Rodgers

unread,
May 17, 1996, 3:00:00 AM5/17/96
to
0 new messages