简体   繁体   English

在C#中存储用户特定数据的最佳方法是什么?

[英]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.

相关问题 在C#中存储永远不变的静态数据的最佳方法是什么 - What is the best way to store static data in C# that will never change 在C#中存储和排序数据的最佳方式 - Best Way To Store and Sort Data in C# 在 C# 应用程序中,存储(Twitch)用户访问和 ID 令牌的最佳方式是什么? - In a C# app, what is the best way to store a (Twitch) User Access and ID tokens? 在C#Windows窗体应用程序中存储/读取多个用户设置的最佳方法是什么? - What is the best way to store/read multiple user settings in a C# Windows Form Application? 继承需要存储特定于子类的数据的数组的最佳方法是什么? - What is the best way to inherit an array that needs to store subclass specific data? 存储/设置C#应用程序配置设置的最佳方法是什么? - What is the best way to store/set configuration settings for a C# application? 在 C# 中的字典中存储类似对象的最佳方法是什么? - What is the best way to store similar objects in a dictionary in C#? 在MySQL中使用C#Windows窗体,什么是清除用户数据的最佳方法。 - Using a C# windows form with MySQL, what is the best way to sanitise the user data. 在 .NET (C#) 中本地存储数据的最佳方式 - Best way to store data locally in .NET (C#) 在C#UWP应用中存储传感器数据的最佳最快方法 - Best and fastest way to store sensor data in C# UWP app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM