I have enabled the installation log in Inno Setup using SetupLogging = yes.
It is creating a log file temp directory and I'm copying that log to my program data:
procedure DeinitializeSetup();
var
logfilepathname, newfilepathname: string;
begin
logfilepathname := ExpandConstant('{log}');
newfilepathname := 'ProgramData\InstallerlogFile'
FileCopy(logfilepathname, newfilepathname, false);
end;
Every time I create a new installer it replaces the content of the older file in program data. I wanted to append new log content instead of replacing it.
The easiest way to append not-too-huge contents from one file to another is using
LoadStringFromFileandSaveStringToFile:Or you can just execute
copy"cmd" command usingExec, when "dest" exists already (if not, use yourFileCopycode):But that won't work for the log, as it is locked by the installer proces. To read a locked file, you need to resort to more low-level functions. You can use
TFileStreamwith itsfmShareDenyNone.For an example, see
FileCopyUnrestrictedin my answer toHow can I copy the installer to the temp file and then run it?
To make it append, replace the
with
ModeisWordvariableTFileStream, you can optimize the code not to load whole contents to memory at once, in case you need it. You do not, for the log file, as it is not too huge.