Windows应用程序数据目录
通过环境变量 %allusersprofile% 我可以获得存储常用设置的目录。但大多数程序将其设置存储在子文件夹“anwendungsdaten”(德语,应用程序数据)中。有没有办法获得该文件夹的直接路径?问题是它的名称依赖于语言。 谢谢。
With the environment variable %allusersprofile% I can get the directory where common settings are stored. But most programs store their settings in the sub-folder "anwendungsdaten" (German, application data). Is there a way to get the direct path to this folder? The problem is that its name is language dependent.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不确定您使用的是什么编程语言,所以我假设使用基本的 Windows api。在 XP 中,您可以使用 CSIDL_COMMON_APPDATA 调用 SHGetFolderPath一个参数。看起来 Vista 和 7 有一组新函数< /a> 做同样的事情,你可能想调用 SHGetKnownFolderPath。
在 Windows 窗体中,您可以使用 Application.UserAppDataPath 属性。
Not sure about what programming language you're using, so I'll assume the basic Windows api. In XP you can call SHGetFolderPath with CSIDL_COMMON_APPDATA as a parameter. It looks like Vista and 7 have a new set of functions that do the same thing, you'd probably want to call SHGetKnownFolderPath.
In Windows Forms, you can use the Application.UserAppDataPath property.
我看不到任何直接的方法来直接获取这些信息。如果没有出现其他问题,唯一想到的就是一些可能在 99% 的情况下都有效的 hacky:
Take
%USERPROFILE%
取
%APPDATA%
取
%APPDATA%
并且将%USERPROFILE%
替换为 null。 “其余”应该是“/Application Data”或“/Anwendungsdaten”或其他任何内容采用
%ALLUSERSPROFILE%
将步骤 3. 的结果添加到其中
您最终应该得到“所有用户”配置文件的“Appdata”目录的正确本地化路径。< /p>
注意:这未经测试,我在这个领域几乎没有经验。但它可能会起作用。
I can't see any direct way to get hold of this information directly. If nothing else comes up, the only thing that comes to mind is something hacky that will probably work in 99% of all cases:
Take
%USERPROFILE%
Take
%APPDATA%
Take
%APPDATA%
and replace%USERPROFILE%
by null. The "rest" should be "/Application Data" or "/Anwendungsdaten" or whateverTake
%ALLUSERSPROFILE%
Add the result of step 3. to it
You should end up with the correct, localized path to the "Appdata" directory of the "All users" profile.
Note: This is untested and I have little experience in this field. But it might work.
我不知道有任何直接的方法来获取它,但是如果您关心语言,那么您可以抓住 %APPDATA% 的末尾,从最后一个 '\' 符号到字符串的末尾,并将其附加到 %allusersprofile %。
I'm not aware of any direct way to get it, but if language is your concern then you could grab the end of %APPDATA%, from the last '\' symbol to the end of the string, and append that to %allusersprofile%.