Here's a function we've used...

function MyCopyFile(Source, Dest: string): Integer;
{ This procedure is a modified version of the CopyFile procedure published in }
{ Borland's Delphi Developer's Guide (p.777-780).                             }
var
  SourceHand, DestHand: Integer;
  PSource, PDest: PChar;
  ASource: array[0..500] of Char;
  ADest: array[0..500] of Char;
  OpenBuf: TOFStruct;
begin
  Result := 0;
  PSource := @ASource[0];
  PDest := @ADest[0];
  StrPCopy(PSource, Source);
  StrPCopy(PDest, Dest);
  { Open source file and pass the filename }
  SourceHand := LZOpenFile(PSource, OpenBuf, of_Share_Deny_Write or of_Read);
  { raise an exception on error }
  if Sourcehand <> -1 then
  begin
    { Open destination file and pass the filename }
    DestHand := LZOpenFile(@Dest[1], OpenBuf, of_Share_Exclusive or of_Write or 
of_Create);
    { Check for error (copy the file if no error) }
    if DestHand <> -1 then
      try
        LZCopy(SourceHand, DestHand);
      except
        Result := -1;
      end
    else
      Result := -1;
    LZClose(DestHand);
  end
  else
    Result := -1;
  { whether or not an error occurs, we need to close the files }
  LZClose(SourceHand);
end;

Cheers.
                        BJ...


----------
From:   [EMAIL PROTECTED][SMTP:[EMAIL PROTECTED]]
Reply To:       [EMAIL PROTECTED]
Sent:   Friday, 11 June 1999 13:05
To:     Multiple recipients of list delphi
Subject:        [DUG]:  File copying

Whats the easiest way to copy files from delphi,

execute s shell program ?
write a copy FileObject that uses blockread/write ?

I Have to do a whole stack of files and directories ??

Richard


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to