[英]What is the best way to to store user specific data in C#?
I want every user (windows user) to have his/her own settings in my app. 我希望每个用户(Windows用户)都能在我的应用中拥有自己的设置。 What's the best way to do that?
最好的方法是什么?
Should I check for the username or is it done automatically? 我应该检查用户名还是自动完成? Will it be compatible with every Windows version from XP through to Windows 8?
它是否兼容从XP到Windows 8的每个Windows版本?
将settings.settings添加到项目中。
If you add settings properties to your project then you could specify USER and APPLICATION settings predefined for your application. 如果向项目添加设置属性,则可以指定为应用程序预定义的USER和APPLICATION设置。
When the application run, you update the settings specific for the current user and then you save these settings calling 应用程序运行时,您将更新特定于当前用户的设置,然后保存这些设置
Properties.Settings.Default.Save();
this method will create a file called user.config
under the path 此方法将在路径下创建名为
user.config
的文件
%AppData%\CompanyName\ExeName_Url_hashcode\Version\
containing the settings for the current user. 包含当前用户的设置。
This file will be reloaded when the same user will restart your application. 当同一用户重新启动您的应用程序时,将重新加载此文件。
You don't have to do any further work. 你不需要做任何进一步的工作。 The saved USER settings will be there to use.
保存的USER设置将在那里使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.