type
stsize = array[0..1] of longint;
var
anz: stsize;
fs1, fs2: TFileStream;
function zusammen(vordere, hintere: string): stsize;
begin
fs1 := TFileStream.create(vordere, fmOpenReadWrite or fmShareDenyWrite);
result[0] := fs1.size;
fs2 := TFileStream.create(hintere, fmOpenRead or fmShareDenyNone);
fs1.seek(0, soFromEnd);
fs1.CopyFrom(fs2, 0);
result[1] := fs1.size;
fs1.free;
fs2.free;
end;
procedure auseinander(gekuerzt, neu: string);
begin
fs1 := TFileStream.create(gekuerzt, fmOpenReadWrite or fmShareDenyWrite);
fs2 := TFileStream.create(neu, fmCreate or fmShareDenyNone);
fs1.seek(anz[0], soFromBeginning);
fs2.CopyFrom(fs1, anz[1] - anz[0]);
fs1.seek(0, soFromBeginning);
fs1.size := anz[0];
fs1.free;
fs2.free;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
anz := zusammen('c:\temp\text.txt', 'c:\temp\bild.bmp');
showmessage('Die Datei ist von ' + inttostr(anz[0]) + ' auf ' +
inttostr(anz[1]) + ' Byte angewachsen.');
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
auseinander('c:\temp\text.txt', 'c:\temp\wiederbild.bmp');
end;