«« Site Rescued »»

While the site is still going to move from its current host, a new site will now take its place. More Info.

The new site may have less content, but the core will now remain. And it will now play nicely with phones! Keep an eye on the DelphiDabbler Blog for news.

» Help

Merging files

   

The following routine merges a file of files specified in a string list (Files) into a single target file (TargetFile whose name is specified as a string. Note TargetFile should not also be in Files or an error will be reported.

procedure MergeFiles(const Files: TStrings; const TargetFile: string);
var
  I: Integer;
  InStm, OutStm: TFileStream;
begin
  OutStm := TFileStream.Create(TargetFile, fmCreate);
  try
    for I := 0 to Pred(Files.Count) do
    begin
      InStm := TFileStream.Create(Files[I], fmOpenRead);
      try
        OutStm.CopyFrom(InStm, 0);
      finally
        InStm.Free;
      end;
    end;
  finally
    OutStm.Free;
  end;
end;

Original code contributed by Rubem Nascimento da Rocha and adpated by Peter Johnson

Author: R Nascimento da Rocha/P Johnson
Contributor: Rubem Nascimento da Rocha
Added: 2008-03-31
Last updated: 2008-03-31

« Return to contents »