Merge any two files, regardless of their type.
1 2 3 4 5 6 7 8 |
var file1, file2, destFile: WideString; begin file1:= 'c:\1.txt'; file2:= 'c:\2.txt'; destFile:= 'c:\12.txt'; mergeFiles(file1, file2, destFile); end; |
Options
file1 , file2 - files to be merged
destFile - the file into which you want to save the merged file1 and file2
Result
True if the operation is successful or False if not.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
function mergeFiles(file1, file2, destFile: Widestring): Boolean; var fs1, fs2, fsOut:TFileStream; begin try fs1:=TFileStream.Create(file1, fmOpenRead); fs2:=TFileStream.Create(file2, fmOpenRead); fsOut:=TFileStream.Create(destFile, fmCreate); fsOut.CopyFrom(fs1, fs1.size); fsOut.CopyFrom(fs2, fs2.size); fs1.free; fs2.free; fsOut.free; Result:= True; except Result:= False; end; end; |