Merging files #60
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 |