当我在 install4j 中使用相对路径然后在该相对路径上使用 getCanonicalPath() 方法时它 return 错误的绝对路径?

When I am using relative path in install4j and then use getCanonicalPath() method on that relative path it return wrong absolute path?

就像我使用 data/conf/filename.txt 作为相对路径,其正确的绝对路径是 C:/username/data/conf 而不是 install4j return C:/Windows/temp/e4j906.tem_dir477546661/data/conf/filename.txt.

相对于工作目录解析相对路径。对于由 install4j 生成的安装程序,工作目录位于临时目录中。

你必须自己构建绝对目录。如果在用户主目录下:

new File(System.getProperty("user.home", "data/conf/filename.txt"))

如果在安装目录下,上下文有解析文件的方法:

context.getDestinationFile("data/conf/filename.txt")