inno-setup - 安装空文件夹时访问 CurrentFileName 时出现 Inno Se

我试图通过 Pascal 代码访问文件夹中的所有文件。当我遍历一个空文件夹时,出现以下错误:

Exception: Internal error; An attempt was made to call the "CurrentFileName" function from outside a "Check", "BeforeInstall" or "AfterInstall" event function belonging to a "[Files]" entry

我使用的代码:

[Files]
Source: ".\3D_Dlls\*"; DestDir: {app}\3D_Dlls; \
    Flags: ignoreversion recursesubdirs createallsubdirs skipifsourcedoesntexist; \
    Check: FileBackup    

[Code]
function FileBackup(): Boolean; 
var FileName,Source,Target,TargetDir: String; 
begin 
  Result := True;
  Source := ExpandConstant(CurrentFileName);
end

比如说我的文件夹结构是这样的:

3D_Dlls
-   Folder 1
-   Folder 2 // Empty folder and it invokes the problem
-   Folder 3

最佳答案

我相信这是 Inno Setup 中由 createallsubdirs 标志触发的错误。

当指定标志时,Inno Setup 会收集一个单独的空目录列表,这些空目录需要在安装期间显式创建。 “安装”空文件夹时,对 CurrentFileName 的调用会失败。

解决方法:

  • 如果可能,删除 createallsubdirs 标志。

    相反,您可以使用 [Dirs] section 显式创建空目录.

  • 捕获异常:

    function FileBackup: Boolean; 
    begin 
      Result := True;
      try
        Source := ExpandConstant(CurrentFileName);
      except
        Log(GetExceptionMessage);
      end;
    end;
    

我已经在 Inno Setup 新闻组上报告了这一点,但此后新闻组已重置。

关于inno-setup - 安装空文件夹时访问 CurrentFileName 时出现 Inno Setup Runtime 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29112881/

相关文章:

amazon-redshift - AWS Redshift 是否支持副本?

c# - 如何在 LINQ to DB 模型类中添加表之间的关系

netlogo - 如何在 Netlogo 中的海龟之间创建多个链接

doctrine-orm - Doctrine2 会选择所有关联的所有字段(来自查询的 JOINS)

r - Error in `[<-` (`*tmp*` , , 下标越界 下标越界

clojure - 我如何获得 clojure 中的单元测试列表?

html - 高度以像素为单位,而不是百分比

ruby-on-rails - rails : validate unique friendship

c# - 使用 C# 的条件 JSON 序列化

can-bus - 使用 ELM327 接收 CAN 报文时的流量控制报文