Beranda > Delphi > Merging filesMerging files

Merging filesMerging 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;
Iklan
Kategori:Delphi
  1. Belum ada komentar.
  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: