简体   繁体   English

访问计算机的默认AppData文件夹

[英]Access Computer's Default AppData Folder

I am currently trying to use the following to access a computer's local AppData folder: 我目前正在尝试使用以下内容来访问计算机的本地AppData文件夹:

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

This returns something along the lines of C:\\\\Users\\\\[USERNAME]\\\\AppData\\\\Roaming . 这将返回C:\\\\Users\\\\[USERNAME]\\\\AppData\\\\Roaming What I want is to get the default AppData folder, as opposed to any specific user's folder. 我想要的是获取默认的AppData文件夹,而不是任何特定用户的文件夹。

I can hard code this C:\\Users\\Default\\AppData\\Local , but I'd feel more comfortable if there was a function that provided what I'm looking for. 我可以硬编码这个C:\\Users\\Default\\AppData\\Local ,但如果有一个功能提供了我正在寻找的东西,我会感觉更舒服。

Is there such a function, and if so, what is it? 是否有这样的功能,如果有,它是什么?

I believe SpecialFolder.CommonApplicationData will get what you need. 我相信SpecialFolder.CommonApplicationData将获得您所需要的。

From the MSDN documentation : MSDN文档

The directory that serves as a common repository for application-specific data that is used by all users. 该目录充当所有用户使用的特定于应用程序的数据的公共存储库。

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

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