How can I rename an INI file in Inno Setup?
I have this in my installer and I need to change the name of the ini file.
[INI]
Filename: {app}\bin\old.ini; Section: Data; Key: key; String: Value;
If I just change the filename, it creates a different ini file and I lose data.
Is there an easy way to rename this ini file to installer?
0
source to share
2 answers
Just to be more detailed because of PhiLho's answer:
In the [INI] section of the installer, just change everything to the new .ini file, then rename the old file in the ssInstall step as follows:
procedure CurStepChanged(CurStep: TSetupStep);
var
OldFile: string;
begin
if CurStep = ssInstall then
begin
OldFile := ExpandConstant('{app}\old.ini');
if FileExists(OldFile) then
RenameFile(OldFile, ExpandConstant('{app}\new.ini'));
end;
end;
It works as expected because ssInstall occurs before the [INI] section, so when the installer tries to create a new .ini file, the old one will already be renamed and it will simply update any entries if necessary.
+1
source to share