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----
Dan.
On 14 May 1996 04:28:00 GMT, guil...@tigger.cs.colorado.edu (Troy
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
\\\\\\\\\\\\\\\\\\
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;
Chad Z. Hower wrote:
> ... This is from the DELPHI HELP FILE..... (Slightly modified)
>
> procedure FileCopy(const sFrom, sTo: String); ...