After the user logins in the program, I want that my program remembers the username of the last user and when the program reopens, the username filed is filled automatically with the username of that last user.
I want to know how to save and restore username. I dont want to use a database.
A better solution than temporary files is simply to use application settings.
To set the last username:
Properties.Settings.Default.LastUsername = theUsername;
Properties.Settings.Default.Save();
Then you can access Properties.Settings.Default.LastUsername any time you want to use the last username.
System.IO.File.WriteAllText(path, Environment.UserName);
System.IO.File.ReadAllText(path);
Something like that should work i did not wrote the code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With