Java api 获取 Microsoft Windows 特殊文件夹

发布于 2024-09-03 10:00:32 字数 198 浏览 1 评论 0原文

我曾经发现一个漂亮的小库,它使用 JNI 允许 Windows 上的 java 应用程序获取 Windows 上各种“特殊”目录的位置。我一生都无法再次找到它......

特别是,我需要获取“所有用户”(共享)“应用程序数据”目录的位置。

那么,有人有 Java 中的防弹方法来定位“所有用户”“应用程序数据”文件夹吗?

它需要防弹。

I once found a nifty little library that used JNI to allow java applications on Windows to get the locations of various "special" directories on windows. I can't for the life of me find it again...

In particular, I need to get the location of the "All Users" (shared) "Application Data" directory.

So, anyone have a bullet proof way in Java to locate the "All Users" "Application Data" folder?

It needs to be bullet proof.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

妄想挽回 2024-09-10 10:00:32

您可能想研究环境变量:

http://en.wikipedia.org/wiki/Environment_variable# DOS_and_Windows
http://en.wikipedia.org/wiki/Environment_variable#System_path_variables

System.getenv() 方法提供系统环境变量的列表,它包含在核心库中。没有比这更防弹的了。

You might want to research Environment Variables:

http://en.wikipedia.org/wiki/Environment_variable#DOS_and_Windows
http://en.wikipedia.org/wiki/Environment_variable#System_path_variables

The System.getenv() method offers a list of the system's environment variables and it's included in the core library. Doesn't get much more bullet-proof than that.

舞袖。长 2024-09-10 10:00:32

您可以在环境中使用以下属性:
ALLUSERSPROFILE=C:\Documents and Settings\All Users

编辑:从 Windows Vista 及更高版本开始,此功能不再有效。

You could use the following property in the environment:
ALLUSERSPROFILE=C:\Documents and Settings\All Users

Edit: This no longer works as of Windows Vista and newer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文