我应该在哪里存储非漫游用户的计算机范围的应用程序设置?
我有一个 WPF 应用程序,必须为具有相同设置的计算机的所有用户运行。设置必须是读/写的。例如,我之前一直将用户配置设置存储在 CommonApplicationData 中,
var settingsFile = Path.Combine(Environment.GetFolderPath(
Environment.SpecialFolder.CommonApplicationData),
"[company]", "[product]", "settings.xml");
但是今天早上我读到 CommonApplicationData 用于漫游配置文件,这意味着它们不是特定于计算机的。据我所知,我们有以下应用程序数据选项(source):
// Store application-specific data for the current roaming user.
// A roaming user works on more than one computer on a network.
// A roaming user's profile is kept on a server on the network and is loaded onto a system ' when the user logs on.
System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
// Store in-common application-specific data that is used by all users.
System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
// Store application-specific data that is used by the current, non-roaming user.
System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
总而言之,选项是
- 单用户,漫游
- 所有用户,漫游
- 单用户,非漫游
我需要的是全部用户,非漫游。我最初的想法是将其全部放入安装文件夹中,但这似乎有点老派?
想法?
I have a WPF application that must run for all users of a machine with the same settings. The settings must be read/write. I have previously been storing user configuration settings in CommonApplicationData, for example
var settingsFile = Path.Combine(Environment.GetFolderPath(
Environment.SpecialFolder.CommonApplicationData),
"[company]", "[product]", "settings.xml");
However I read this morning that CommonApplicationData
is used for roaming profiles, meaning they are not machine specific. From what I can find, we have the following options for application data (source):
// Store application-specific data for the current roaming user.
// A roaming user works on more than one computer on a network.
// A roaming user's profile is kept on a server on the network and is loaded onto a system ' when the user logs on.
System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
// Store in-common application-specific data that is used by all users.
System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
// Store application-specific data that is used by the current, non-roaming user.
System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
To summarize, the options are
- Single user, roaming
- All users, roaming
- Single user, non-roaming
What I need is all users, non-roaming. My initial thought is to chuck it all into the install folder, but that seems a little old-school?
Thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是 appdata 文件夹的一个很好的解释以及其他与漫游用户相关的项目。
根据 MSDN 文档:
CommonApplicationData< /code> 是“充当所有用户使用的应用程序特定数据的公共存储库的目录”
,而
LocalApplicationData
是“充当所有用户使用的应用程序特定数据的公共存储库的目录”。被当前使用,非漫游用户”。Here is a good explanation of the appdata folder and other items related to roaming user.
According to the MSDN Documentation:
CommonApplicationData
is "the directory that serves as a common repository for application-specific data that is used by all users"whereas
LocalApplicationData
is "the directory that serves as a common repository for application-specific data that is used by the current, non-roaming user".我对此的偏好是应用程序设置,它可以是应用程序范围的或每个用户的根据您的意愿进行设置。
My preference for this is Application Settings which can be application wide or per user as you wish per setting.