简体   繁体   English

Inno Setup Compiler-JavaFX应用程序不写入文件

[英]Inno Setup Compiler - JavaFX app doesn't write files

I have written a simple JavaFx app that visits a series of urls using PhantomJS and saves screenshots to a folder in the same directory. 我编写了一个简单的JavaFx应用程序,该应用程序使用PhantomJS访问一系列URL,并将屏幕截图保存到同一目录中的文件夹中。 For example if the jar/exe is located in the folder "my-app", it will save the screenshots to "my-app/screenshots" just fine. 例如,如果jar / exe位于文件夹“ my-app”中,它将截图保存到“ my-app / screenshots”中。 However, after using Inno Setup Compiler to create an installer, installing the app on my own computer, and then running the version created by the installer, it fails to save anything. 但是,在使用Inno Setup Compiler创建安装程序,在我自己的计算机上安装应用程序,然后运行由安装程序创建的版本后,它无法保存任何内容。 What could the issue be? 可能是什么问题? This is an example of what my code looks like when creating/saving an image: 这是创建/保存图像时我的代码的示例:

byte[] bytes = phantomDriver.getScreenshotAs(OutputType.BYTES);
File outputFile = new File(outputFolder, String.format("/Home Page/Home_Page-%s.jpg", timestamp));
outputFile.getParentFile().mkdirs();
FileUtils.writeByteArrayToFile(outputFile, bytes);

Thanks for any help in advance 感谢您的任何帮助

Applications typically install to Program Files files. 应用程序通常安装到Program Files文件中。 You cannot write files there (unless the application runs with elevated privileges, what is not recommended). 您不能在此处写入文件(除非应用程序以提升的特权运行,否则不建议这样做)。

You should modify the application to write files to a user profile or to a configurable location. 您应该修改应用程序以将文件写入用户配置文件或可配置位置。

If the application writes to the current working directory, as a quick hack, you can modify the shortcuts, created by the installer, to set the working directory to user profile. 如果应用程序快速地写入当前工作目录,则可以修改安装程序创建的快捷方式,以将工作目录设置为用户配置文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM