InnoSetup为install.log制作{app}目录

时间:2014-07-07 16:33:13

标签: installation inno-setup

我需要在安装目标文件夹({app})中创建所选组件的install.log,但是当我运行安装程序时说“文件不存在C:/ tmp / exe”时我遇到了问题/install.log“我假设这意味着它还没有创建dir”exe“。我怎么能绕过这个呢?

procedure CurStepChanged(CurStep: TSetupStep);
var
  I: Integer;
  LogList: TStringList;
begin
  if CurStep = ssInstall then
  begin
    LogList := TStringList.Create;
    try
      LogList.Add('Selected components:');
      for I := 0 to WizardForm.ComponentsList.Items.Count - 1 do
        if WizardForm.ComponentsList.Checked[I] then
          LogList.Add('Component: ' + WizardForm.ComponentsList.ItemCaption[I]);

      LogList.SaveToFile(ExpandConstant('{app}\install.log'));
    finally
      LogList.Free;
    end;
  end;
end;

1 个答案:

答案 0 :(得分:1)

我怀疑您在此过程中过早地尝试访问该文件夹,然后才真正创建该文件夹。

尝试更改为此过程中的后续步骤,例如ssPostInstall。此时,您将确定已创建该文件夹。其余代码应该保持不变。

procedure CurStepChanged(CurStep: TSetupStep);
var
  I: Integer;
  LogList: TStringList;
begin
  if CurStep = ssPostInstall then
  begin
    LogList := TStringList.Create;
    try
      LogList.Add('Selected components:');
      for I := 0 to WizardForm.ComponentsList.Items.Count - 1 do
        if WizardForm.ComponentsList.Checked[I] then
          LogList.Add('Component: ' + WizardForm.ComponentsList.ItemCaption[I]);

      LogList.SaveToFile(ExpandConstant('{app}\install.log'));
    finally
      LogList.Free;
    end;
  end;
end;