简体   繁体   English

如何使用C#将已登录用户的信息存储在桌面应用程序中

[英]How to store information of logged in User in desktop application using c#

We want to keep track of which User is logged in at the moment. 我们要跟踪当前登录的用户。 Instead uf using for example: Environment.Username we want to know the Username from our database. 取而代之的是,例如,uf使用例如:Environment.Username我们想从数据库中知道用户名。 We are able to get the Username from the database but we want to store it somewhere. 我们可以从数据库中获取用户名,但是我们希望将其存储在某个地方。 Any solutions? 有什么办法吗?

An example from the question linked below: 来自下面链接的问题的示例:

Settings.Default["SomeProperty"] = "Some Value"; Settings.Default [“ SomeProperty”] =“某些值”;
Settings.Default.Save(); Settings.Default.Save(); // Saves settings in application configuration file //将设置保存在应用程序配置文件中

I recommend to have a glance at this question . 我建议看一下这个问题

Best practice to save application settings. 保存应用程序设置的最佳实践。 There are other solutions as well. 还有其他解决方案。

They are several solutions: 它们是几种解决方案:

  • Using MVVM, create shared user manager service(recommended). 使用MVVM,创建共享的用户管理器服务(推荐)。

  • Singleton service. 单例服务。

  • Application settings. 应用程序设置。

  • Static variable. 静态变量。

如果您的应用程序由多个用户使用,则您可以将数据存储在CSV,XML等传统文件中。但是,使用这种技术可能无法获得数据安全性,因此可以使用二进制序列化。

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

相关问题 如何使用C#进行多语言桌面应用程序 - How to multilanguage desktop application using c# 在登录用户且桌面已锁定的情况下,如何使用Task Scheduler从C#Interop / COM程序中自动执行Word 2013? - How can Word 2013 be automated from a C# Interop/COM program using Task Scheduler with a user logged on and the desktop locked? 我可以使用C#将用户信息存储到本地存储中吗 - Can I store user information to local storage using c# 如何使用C#通过他的ID获取当前登录用户? - How to get currently logged in user by his ID using C#? C#-如何检查用户是否使用HttpWebRequest登录到网络 - C# - How to check if a user logged in into a web using HttpWebRequest 在c#中,如何使用登录用户启动新流程? - In c# How to Start new Process using logged on user? 将登录的用户信息传递给另一种形式的C#MySQL - Passing logged in user information to another form c# mysql 如何使用C#.Net在桌面应用程序中实现OAuth 1.0 - How to implement OAuth 1.0 in a desktop application using C# .Net 如何使用C#桌面应用程序创建HTML文件 - How to create an HTML file using C# desktop application 如何使用C#和eStreamchat在聊天应用程序中获取桌面通知? - How to get desktop notification in chat application using c# and eStreamchat?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM