我需要在安装目标文件夹({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;发布于 2014-07-07 17:11:47
我怀疑在创建文件夹之前,您正在试图在这个过程的早期访问该文件夹。
尝试更改为流程中的稍后步骤,例如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;https://stackoverflow.com/questions/24615477
复制相似问题