简体   繁体   中英

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. 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.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).

  • Singleton service.

  • Application settings.

  • Static variable.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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