> Any suggestions on a better method?

uses
  classes, sysutils;

....

procedure CopyFile(filename, newfilename: string);
var
  oldfile, newfile: TFilestream;
begin
  oldfile := TFileStream.Create(filename, fmOpenRead); //might need
fmShareXXX style stuff too
  try
    oldfile.Position := 0; //could use TStream.Seek(..) here also..
    newfile := TFileStream.Create(newfilename, fmCreate);
    try
      newfile.CopyFrom( oldfile, oldfile.size );
    finally
      newfile.free; // be careful.. file not actually closed till this
point...
    end;
  finally
    oldfile.free; //this closes the file..
  end;
end;


No legacy Assign[File] (or rewrite etc) in sight too.

Matt


_______________________________________________
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to