Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. remember user name password in login form? [modified]

remember user name password in login form? [modified]

Scheduled Pinned Locked Moved C#
csharpvisual-studiotutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    charles henington
    wrote on last edited by
    #1

    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();
        }
    }
    

    }

    S 1 Reply Last reply
    0
    • C charles henington

      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();
          }
      }
      

      }

      S Offline
      S Offline
      Stanciu Vlad
      wrote on last edited by
      #2

      Yes, Using Settings in C#[^], Oh, and try not to save passwords in plain form, encrypt them first.

      I have no smart signature yet...

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups