Streams are easy.
Takes two existing files and appends the first to the second.
program inoutstream;
uses
classes,sysutils;
var
Instream,OutStream:TFilestream;
begin
if (ParamCount = 2) and
FileExists(ParamStr(1)) and
FileExists(ParamStr(2)) then
begin
instream := TFilestream.Create(ParamStr(1), fmOpenRead);
try
outstream :=TFilestream.Create(Paramstr(2), fmOpenwrite);
try
outstream.position := Outstream.size;
outstream.copyfrom(instream,0);// appends
finally
instream.free;
end;
finally
outstream.free;
end;
end else writeln('use: inoutstream <infile> <outfile>');
end.
I will add this to the wiki, because it is a much better example
The wiki is cluttered and needs a rewrite because of hopelessly incapable example code. Almost everything works, but almost all the object oriented examples are plain bad. It is on my agenda.