![]() |
Datei aneinanderhängen (copy /b file1.dat + file2.dat)
Folgende Funktionen kopieren 2 oder mehrere Dateien aneinander.
Die Dateien werden binär kopiert; vergleichbar mit dem MS DOS-Befehl
Code:
copy /B fileA + fileB fileA
Delphi-Quellcode:
[edit=Matze]Code formatiert. Mfg, Matze[/edit]interface function ConcatFiles(const DstFile,SrcFile: string; const DeleteDst: Boolean = False): Boolean; overload; function ConcatFiles(const DstFile :string; const SrcFiles: TStrings; DeleteDst: Boolean = True): Boolean; overload; implementation function ConcatFiles(const DstFile,SrcFile: string; const DeleteDst: Boolean = False): Boolean; const DefaultBlockSize = 8 * 1024; var SrcStream,DstStream: TFileStream; begin Result := False; // default: "ConcatFiles failed" SrcStream := TFileStream.Create(SrcFile,fmOpenRead); try if DeleteDst then DeleteFile(DstFile); if not FileExists(DstFile) then begin DstStream := TFileStream.Create(DstFile,fmCreate); end else begin DstStream := TFileStream.Create(DstFile,fmOpenWrite); DstStream.Position := DstStream.Size; end; while SrcStream.Position < SrcStream.Size do begin DstStream.CopyFrom(SrcStream,Min(DefaultBlockSize,SrcStream.Size-SrcStream.Position)); end; Result := True; // ConcatFiles successfull except SrcStream.Free; DstStream.Free; end; end; function ConcatFiles(const DstFile: string; const SrcFiles: TStrings; DeleteDst: Boolean): Boolean; var iFile: Integer; begin Result := False; for iFile := 0 to SrcFiles.Count-1 do begin Result := ConcatFiles(DstFile,SrcFiles[iFile],DeleteDst); DeleteDst := False; if Result = false then Break; end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:33 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz