Click here to Skip to main content
15,913,115 members
Home / Discussions / C#
   

C#

 
RantSOLVED Pin
jojoba20118-May-10 23:35
jojoba20118-May-10 23:35 
Questionremember user name password in login form? [modified] Pin
charles henington8-May-10 19:28
charles henington8-May-10 19:28 
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();
        }
    }
}


modified on Sunday, May 9, 2010 1:35 AM

AnswerRe: remember user name password in login form? Pin
Stanciu Vlad8-May-10 20:58
Stanciu Vlad8-May-10 20:58 
QuestionSQL server name not found:Admin-PC\MSSQLSERVER,1433 Pin
Tunisien868-May-10 4:58
Tunisien868-May-10 4:58 
AnswerRe: SQL server name not found:Admin-PC\MSSQLSERVER,1433 Pin
Abhinav S8-May-10 5:21
Abhinav S8-May-10 5:21 
GeneralRe: SQL server name not found:Admin-PC\MSSQLSERVER,1433 Pin
Tunisien868-May-10 5:58
Tunisien868-May-10 5:58 
AnswerRe: SQL server name not found:Admin-PC\MSSQLSERVER,1433 Pin
Abhinav S8-May-10 9:06
Abhinav S8-May-10 9:06 
AnswerRe: SQL server name not found:Admin-PC\MSSQLSERVER,1433 Pin
Stanciu Vlad8-May-10 6:34
Stanciu Vlad8-May-10 6:34 
GeneralRe: SQL server name not found:Admin-PC\MSSQLSERVER,1433 Pin
Tunisien868-May-10 10:02
Tunisien868-May-10 10:02 
GeneralRe: SQL server name not found:Admin-PC\MSSQLSERVER,1433 Pin
Stanciu Vlad8-May-10 10:15
Stanciu Vlad8-May-10 10:15 
GeneralRe: SQL server name not found:Admin-PC\MSSQLSERVER,1433 Pin
Tunisien868-May-10 10:47
Tunisien868-May-10 10:47 
GeneralRe: SQL server name not found:Admin-PC\MSSQLSERVER,1433 Pin
Stanciu Vlad8-May-10 11:04
Stanciu Vlad8-May-10 11:04 
GeneralRe: SQL server name not found:Admin-PC\MSSQLSERVER,1433 Pin
Tunisien868-May-10 11:19
Tunisien868-May-10 11:19 
GeneralRe: SQL server name not found:Admin-PC\MSSQLSERVER,1433 Pin
Stanciu Vlad8-May-10 11:32
Stanciu Vlad8-May-10 11:32 
GeneralRe: SQL server name not found:Admin-PC\MSSQLSERVER,1433 Pin
Tunisien868-May-10 12:23
Tunisien868-May-10 12:23 
GeneralRe: SQL server name not found:Admin-PC\MSSQLSERVER,1433 Pin
Tunisien869-May-10 0:10
Tunisien869-May-10 0:10 
AnswerRe: SQL server name not found:Admin-PC\MSSQLSERVER,1433 Pin
Tunisien8611-May-10 5:55
Tunisien8611-May-10 5:55 
GeneralRe: SQL server name not found:Admin-PC\MSSQLSERVER,1433 Pin
Stanciu Vlad11-May-10 6:42
Stanciu Vlad11-May-10 6:42 
GeneralRe: SQL server name not found:Admin-PC\MSSQLSERVER,1433 Pin
Tunisien8611-May-10 9:06
Tunisien8611-May-10 9:06 
QuestionNeed advice for improving performance and making an application more robust Pin
Daniel Jacinto8-May-10 4:21
Daniel Jacinto8-May-10 4:21 
AnswerRe: Need advice for improving performance and making an application more robust Pin
#realJSOP8-May-10 5:02
professional#realJSOP8-May-10 5:02 
Questionhelp about the formating of data to be written on a text file... Pin
aeroboy8-May-10 3:30
aeroboy8-May-10 3:30 
AnswerRe: help about the formating of data to be written on a text file... Pin
OriginalGriff8-May-10 3:54
mveOriginalGriff8-May-10 3:54 
GeneralRe: help about the formating of data to be written on a text file... Pin
aeroboy8-May-10 4:10
aeroboy8-May-10 4:10 
QuestionWhere is network login prompt populated from? Pin
DeepToot8-May-10 3:16
DeepToot8-May-10 3:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.