使用ANSI pascal的例子如下:(Copy file)
Uses
System;
var
F1, F2: File;
NumRead, NumWritten: Integer;
Buf: array[1..4096] of Char;
begin
AssignFile(F1, 'test1.bin');
Reset(F1, 1); // Record size set to 1
AssignFile(F2, 'test2.bin');
Rewrite(F2, 1); // d.o.
repeat
BlockRead(F1, Buf, SizeOf(Buf), NumRead);
BlockWrite(F2, Buf, NumRead, NumWritten);
until (NumRead = 0) or (NumWritten <> NumRead);
CloseFile(F2);
CloseFile(F1);
end;