remember user name password in login form? [modified]
-
Hi I am writing an email program that will have a login form. when you login with the login form (Form1.cs) it will pass the username and pass word to the gmail program (Form2.cs). This is fine and works but I can not fiqure out how to get the settings.setting form to work in order to make sure that the information is remembered. right now I am using streaam reader and stream writer to read and write the username and password to Visual Studio Project User Options File. It works simply by reading from file on textBox enter and writing to on text box exit but was hoping there was a better way to do this? Here is the code that i currently use for this
namespace Email_Client
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();} private void button1\_Click(object sender, EventArgs e) { Email\_Client.Form2 Email = new Email\_Client.Form2(); Email.User.Text = textBox1.Text.ToString(); Email.Pass.Text = textBox2.Text.ToString(); Email.Show(); this.Hide(); } private void textBox1\_Leave(object sender, EventArgs e) { StreamWriter Writer = new StreamWriter(Application.StartupPath + "/acct/info/user.user"); Writer.WriteLine(textBox1.Text); Writer.Close(); } private void textBox2\_Leave(object sender, EventArgs e) { StreamWriter Writer = new StreamWriter(Application.StartupPath + "/acct/info/pass.user"); Writer.WriteLine(textBox2.Text); Writer.Close(); } private void textBox1\_Enter(object sender, EventArgs e) { if (checkBox1.Checked == true) { StreamReader userreader = new StreamReader(Application.StartupPath + "/acct/info/user.user"); textBox1.Text = userreader.ReadToEnd(); userreader.Close(); } } private void textBox2\_Enter(object sender, EventArgs e) { if (checkBox2.Checked == true) { StreamReader passreader = new StreamReader(Application.StartupPath + "/acct/info/pass.user"); textBox2.Text = passreader.ReadToEnd(); passreader.Close(); } } internal static void DestroyHandle() { Form1.ActiveForm.Dispose(); } }
}
-
Hi I am writing an email program that will have a login form. when you login with the login form (Form1.cs) it will pass the username and pass word to the gmail program (Form2.cs). This is fine and works but I can not fiqure out how to get the settings.setting form to work in order to make sure that the information is remembered. right now I am using streaam reader and stream writer to read and write the username and password to Visual Studio Project User Options File. It works simply by reading from file on textBox enter and writing to on text box exit but was hoping there was a better way to do this? Here is the code that i currently use for this
namespace Email_Client
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();} private void button1\_Click(object sender, EventArgs e) { Email\_Client.Form2 Email = new Email\_Client.Form2(); Email.User.Text = textBox1.Text.ToString(); Email.Pass.Text = textBox2.Text.ToString(); Email.Show(); this.Hide(); } private void textBox1\_Leave(object sender, EventArgs e) { StreamWriter Writer = new StreamWriter(Application.StartupPath + "/acct/info/user.user"); Writer.WriteLine(textBox1.Text); Writer.Close(); } private void textBox2\_Leave(object sender, EventArgs e) { StreamWriter Writer = new StreamWriter(Application.StartupPath + "/acct/info/pass.user"); Writer.WriteLine(textBox2.Text); Writer.Close(); } private void textBox1\_Enter(object sender, EventArgs e) { if (checkBox1.Checked == true) { StreamReader userreader = new StreamReader(Application.StartupPath + "/acct/info/user.user"); textBox1.Text = userreader.ReadToEnd(); userreader.Close(); } } private void textBox2\_Enter(object sender, EventArgs e) { if (checkBox2.Checked == true) { StreamReader passreader = new StreamReader(Application.StartupPath + "/acct/info/pass.user"); textBox2.Text = passreader.ReadToEnd(); passreader.Close(); } } internal static void DestroyHandle() { Form1.ActiveForm.Dispose(); } }
}
Yes, Using Settings in C#[^], Oh, and try not to save passwords in plain form, encrypt them first.
I have no smart signature yet...