Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatic login 2

Status
Not open for further replies.

JontyMC

Programmer
Joined
Nov 26, 2001
Messages
1,276
Location
GB
I've created a login control for a windows form app. I want to add a checkbox so users can save their login details and automatically login. Question is this - how and where do I save the login details?

Jon

"I don't regret this, but I both rue and lament it.
 
You can save them just about anywhere you want I guess.

I do most of my saving of data in XML. Something simple like a username and password could be a simple txt file.

I save settings that are application specific to System.Windows.Forms.CommonAppDataPath

And settings that are user specific to System.Windows.Forms.UserAppDataPath

You could also save them to the registry (Not recommended by MS) or to a database, if your application uses one.

And if you want security, you could scramble/encrypt the login and password before saving them to disk
 
What are these:

System.Windows.Forms.CommonAppDataPath?
System.Windows.Forms.UserAppDataPath?

Jon

"I don't regret this, but I both rue and lament it.
 
those are strings, which are directory paths.

UserAppDataPath usually equates to something like:

C:\Documents And Settings\UserName\Application Data\Company Name\Application Name\1.0.0.0

and CommonAppDataPath equates to something like:

C:\Documents And Settings\All Users\Application Data\Company Name\Application Name\1.0.0.0

When I save a users settings file, I use this code:
Code:
using System.Windows.Forms;

mySettings.Save(UserAppDataPath + "\\Settings.xml");
 
Sorry I made a mistake, they should be

System.Windows.Forms.Application.CommonAppDataPath, and
System.Windows.Forms.Application.UserAppDataPath
 
Take a look at the AppSettings member of the ConfigurationSettings class. It gives you access to a XML file which can hold the entire configuration for your application ( sort of an .INI file, if you want). It is fully customizable, you can write anything you want there. You can store encrypted user/pasword/auto_logon options there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top