[英]How can I prompt users to grant read/write permission to my program
I've made a lovely computer program in Java, equipped with handy jpackage
installers, and I would love to share it with all of the world in a user-friendly manner.我在 Java 中制作了一个可爱的计算机程序,配备了方便
jpackage
安装程序,我很乐意以用户友好的方式与全世界分享它。 As part of its design, my program writes the user's custom settings to a file in the installation directory using an ObjectOutputStream
.作为其设计的一部分,我的程序使用
ObjectOutputStream
将用户的自定义设置写入安装目录中的文件。 Unfortunately the program lacks permission to read and write files in secure folders such as "Program Files".不幸的是,该程序缺乏在“程序文件”等安全文件夹中读取和写入文件的权限。
I can't expect average users to know how to set up a policy file, so is there some way I can automate this process or prompt the user to grant read/write permissions during installation without paying hundreds of dollars to a Code Certifying Authority?我不能指望普通用户知道如何设置策略文件,那么有什么方法可以使这个过程自动化或提示用户在安装过程中授予读/写权限,而无需向代码认证机构支付数百美元? Or should I continue what I'm already doing which is asking users to install the software to their home directory or run the program as administrator?
或者我应该继续我已经在做的事情,即要求用户将软件安装到他们的主目录或以管理员身份运行程序? What do other programmers do in this type of situation?
其他程序员在这种情况下会做什么?
You can use local application data directory for these kind of files.您可以将本地应用程序数据目录用于此类文件。 See What is the cross-platform way of obtaining the path to the local application data directory?
请参阅获取本地应用程序数据目录路径的跨平台方式是什么? for details
详情
You shouldn't write to files to save user settings.您不应该写入文件来保存用户设置。
Java have a much better way of saving settings with Preferences: https://docs.oracle.com/javase/8/docs/api/java/util/prefs/Preferences.html Java have a much better way of saving settings with Preferences: https://docs.oracle.com/javase/8/docs/api/java/util/prefs/Preferences.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.