【发布时间】:2015-11-20 07:23:10
【问题描述】:
在我的脚本中,我正在检查该目录中是否存在一个目录和两个文件。虽然第一次返回正确的值,但第二次检查没有。我已经多次检查这些文件是否存在于指定目录中,但 Inno Setup 总是会告诉我它们不存在。这发生在虚拟 Windows 服务器上,无法在我的本地计算机上重现。在那里它总是返回正确的值。
UpdatePath := ExpandConstant('{app}');
if DirExists(UpdatePath) then begin
ExePath := UpdatePath+'\Application.exe';
ConfigFilePath := UpdatePath+'\Application.exe.config';
if FileExists(ExePath) and FileExists(ConfigFilePath) then begin //this one returns incorrect values
//Do Stuff
end else begin
MsgBox(FmtMessage(CustomMessage('DirPageFileNotFound'), [ExePath, ConfigFilePath]),mbInformation,MB_OK);
Result := False;
end;
end else begin
MsgBox(FmtMessage(CustomMessage('DirPageDirectoryNotFound'), [UpdatePath]),mbInformation,MB_OK);
Result := False;
end;
如您所见,我正在检查一个可执行文件,该可执行文件也可以在双击时执行。它在那里,但 Inno Setup 总是会告诉我它不在那里。是虚拟环境搞砸了吗?这里发生了什么?
【问题讨论】:
-
什么检查失败了?
FileExists(ExePath)?ExePath的确切值是多少? -
该系统上的确切值是
E:\Program Files(x86)\Application\Application.exe和E:\Program Files(x86)\Application\Application.exe.config。哪一个失败了?我会说两者,因为两个文件都在同一个位置。 -
尝试在
if FileExists(ExePath)之前添加if not FindFirst(UpdatePath + '\*', FindRec) then Log('Not found') else repeat Log(FindRec.Name); until not FindNext(FindRec);。它会在日志中记录什么? (代码需要FindRec: TFindRec;变量)。 -
我会的,但这需要一些时间,因为我必须与我们的一位客户交谈,并稍微重写此部分。
-
那么,还要添加什么?到目前为止,我已经添加了你的循环。