我们最近有一个使用INNO脚本安装的应用程序经过重大重组。
不幸的是,应用程序要求某些文件在版本之间保持不变。
更不幸的是,在重组过程中,这些文件的位置发生了变化。
最不幸的是,现在我需要制作一个INNO脚本片段来查看这些文件是否存在,并将它们从原来的位置移动到新位置。
是否可以检查INNO脚本以查看文件(与任何容量的INNO脚本本身无关)是否存在,如果存在,则在安装之前/之后将它们移动到新位置完成了?
我说这些文件与INNO脚本无关,因为它们是用户生成的内容。
答案 0 :(得分:5)
是的,有可能。下面的代码是复制和删除(而不是原始移动或重命名)。
使用ClientContainer
部分实现此逻辑。
有关supported functions和events you can handle的文档相当不错。
如何对开始安装做出反应:
[code]
如何知道文件是否存在
procedure CurStepChanged(CurStep: TSetupStep);
begin
case CurStep of
ssInstall:
begin
// will be executed just before the actual installation starts
end;
ssPostInstall:
begin
// will be executed just after the actual installation finishes
end;
end;
end;
复制文件(覆盖现有文件)
if FileExists(FileName) then
begin
// do something when the file exists
end;
删除文件
if not FileCopy(ExistingFileName, NewFileName: String, false) then
begin
// handle copy error
end;