本文整理自网络,侵删。
Answer 1procedure TForm1.Button1Click(Sender: TObject);var Stream1, Stream2: TFileStream;begin Stream1 := TFileStream.Create('c:\file4', fmCreate or fmShareExclusive); try { first file } Stream2 := TFileStream.Create('c:\file1', fmOpenRead or fmShareDenyNone); try Stream1.CopyFrom(Stream2, Stream2.Size); finally Stream2.Free; end; { next file } Stream2 := TFileStream.Create('c:\file2', fmOpenRead or fmShareDenyNone); try Stream1.CopyFrom(Stream2, Stream2.Size); finally Stream2.Free; end; { and so on } finally Stream1.Free; end;end;Tip by Finn Tolderlund
Answer 2function AppendFiles(Files: TStrings; const DestFile: string): integer;var srcFS, destFS: TFileStream; i: integer; F: string;begin result := 0; if (Files.Count > 0) and (DestFile <> '') then begin destFS := TFileStream.Create(DestFile, fmCreate or fmShareExclusive); try i := 0; while i < Files.Count do begin F := Files(i); Inc(i); if (CompareText(F, DestFile) <> 0) and (F <> '') then begin srcFS := TFileStream.Create(F, fmOpenRead or fmShareDenyWrite); try if destFS.CopyFrom(srcFS, 0) = srcFS.Size then Inc(result); finally srcFS.Free; end; end else begin { error } end; end; finally destFS.Free; end; end;end;
相关阅读 >>
Delphi xe8在firemonkey tlistbox中显示图像
Delphi xe5 for android ttabcontrol 控件
Delphi 实现卸载windows应用程序(类似360软件管家-卸载程序)
windows关机函数exitwindowsex使用大全(适用windows所有操作平台)
更多相关阅读请进入《Delphi》频道 >>