- Specifically getting on Windows the "..\Documents & Settings\All Users, basicaly any path that needs the front end to be dynamically derived based on the OS your software is running on. (Now I need the answer to this)
- the current users My Documents dirctory (okay this has been answered) and basicaly any path that needs the front end to be dynamically derived based on the OS your software is running on.
特别是在Windows上“.. \ Documents&Settings \ All Users,基本上任何需要根据你的软件运行的操作系统动态派生的路径。(现在我需要答案)
当前用户我的文档dirctory(好的,已经回答)和basicaly任何需要根据您的软件运行的操作系统动态导出前端的路径。
3 个解决方案
#1
8
My docs would probably best be handled by accessing:
我的文档可能最好通过访问:
System.getProperty("user.home");
Look up the docs on System.getProperty.
在System.getProperty上查找文档。
#2
3
Any information you can get about the user's environment can be fetched from
您可以从中获取有关用户环境的任何信息
System.getProperty("...");
For a list of what you can get, take a look here: http://mgrand.home.mindspring.com/java-system-properties.htm
有关您可以获得的列表,请查看此处:http://mgrand.home.mindspring.com/java-system-properties.htm
I don't think you'll be able to get the path you require (the All Users path) in an OS dependent way. After all - do other operating systems have an equivalent? Your best bet is to probably inspect:
我认为您无法以操作系统相关的方式获得所需的路径(所有用户路径)。毕竟 - 其他操作系统是否具有同等效力?你最好的选择是检查:
System.getProperty("os.name");
to see if you are running Windows and then if so use "C:\Documents & Settings\All Users\".
查看您是否正在运行Windows,如果是,请使用“C:\ Documents&Settings \ All Users \”。
But you'll be better off just constantly using
但是,只要经常使用你就会更好
System.getProperty("user.home");
(as mentioned by other people) throughout the application. Or alternatively, allow the user to specify the directory to store whatever it is you want to store.
(在其他人的提及中)整个申请。或者,允许用户指定存储您要存储的内容的目录。
#3
0
Specifically getting on Windows the "..\Documents & Settings\All Users, basicaly any path that needs the front end to be dynamically derived based on the OS your software is running on. (Now I need the answer to this)
特别是在Windows上“.. \ Documents&Settings \ All Users,基本上任何需要根据你的软件运行的操作系统动态派生的路径。(现在我需要答案)
The folders below the All Users dir are variable directories in windows. Details can be found in the document about KNOWNFOLDERIDs (CSIDL in older versions). Because this values are system dependent Java does not provide a way to access the values.
All Users dir下面的文件夹是windows中的可变目录。有关KNOWNFOLDERID(旧版本中的CSIDL)的文档中可以找到详细信息。因为这些值是系统相关的,Java不提供访问值的方法。
I think there is in general no equivalent on other operating systems to this windows specific folder. In addition the folder Documents & Settings\All Users is only present in latest windows versions and things are handled differently for e.g Windows 2000 or XP I think.
我认为这个Windows特定文件夹在其他操作系统上通常没有相应的东西。此外,文件夹Documents&Settings \ All Users仅出现在最新的Windows版本中,并且我认为对于例如Windows 2000或XP的处理方式不同。
If you really need this information you should read the microsoft docs and impement a native library or some script invoked by Runtime.exec to provide the information to your java application.
如果您确实需要此信息,则应阅读Microsoft文档并强制使用本机库或Runtime.exec调用的某些脚本来向您的Java应用程序提供信息。
#1
8
My docs would probably best be handled by accessing:
我的文档可能最好通过访问:
System.getProperty("user.home");
Look up the docs on System.getProperty.
在System.getProperty上查找文档。
#2
3
Any information you can get about the user's environment can be fetched from
您可以从中获取有关用户环境的任何信息
System.getProperty("...");
For a list of what you can get, take a look here: http://mgrand.home.mindspring.com/java-system-properties.htm
有关您可以获得的列表,请查看此处:http://mgrand.home.mindspring.com/java-system-properties.htm
I don't think you'll be able to get the path you require (the All Users path) in an OS dependent way. After all - do other operating systems have an equivalent? Your best bet is to probably inspect:
我认为您无法以操作系统相关的方式获得所需的路径(所有用户路径)。毕竟 - 其他操作系统是否具有同等效力?你最好的选择是检查:
System.getProperty("os.name");
to see if you are running Windows and then if so use "C:\Documents & Settings\All Users\".
查看您是否正在运行Windows,如果是,请使用“C:\ Documents&Settings \ All Users \”。
But you'll be better off just constantly using
但是,只要经常使用你就会更好
System.getProperty("user.home");
(as mentioned by other people) throughout the application. Or alternatively, allow the user to specify the directory to store whatever it is you want to store.
(在其他人的提及中)整个申请。或者,允许用户指定存储您要存储的内容的目录。
#3
0
Specifically getting on Windows the "..\Documents & Settings\All Users, basicaly any path that needs the front end to be dynamically derived based on the OS your software is running on. (Now I need the answer to this)
特别是在Windows上“.. \ Documents&Settings \ All Users,基本上任何需要根据你的软件运行的操作系统动态派生的路径。(现在我需要答案)
The folders below the All Users dir are variable directories in windows. Details can be found in the document about KNOWNFOLDERIDs (CSIDL in older versions). Because this values are system dependent Java does not provide a way to access the values.
All Users dir下面的文件夹是windows中的可变目录。有关KNOWNFOLDERID(旧版本中的CSIDL)的文档中可以找到详细信息。因为这些值是系统相关的,Java不提供访问值的方法。
I think there is in general no equivalent on other operating systems to this windows specific folder. In addition the folder Documents & Settings\All Users is only present in latest windows versions and things are handled differently for e.g Windows 2000 or XP I think.
我认为这个Windows特定文件夹在其他操作系统上通常没有相应的东西。此外,文件夹Documents&Settings \ All Users仅出现在最新的Windows版本中,并且我认为对于例如Windows 2000或XP的处理方式不同。
If you really need this information you should read the microsoft docs and impement a native library or some script invoked by Runtime.exec to provide the information to your java application.
如果您确实需要此信息,则应阅读Microsoft文档并强制使用本机库或Runtime.exec调用的某些脚本来向您的Java应用程序提供信息。