Слияние двух любых файлов, независимо от их типа.
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; |
Параметры
file1, file2 - файлы для слияния
destFile - файл в который нужно сохранить "склееные" file1 и file2
Результат
True, если операция успешна или False, если нет.
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; |