Ejemplo n.º 1
0
        /*Method to check their password and open the locker*/
        private void openLocker()
        {
            string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); //path to appdata
            string input   = txtPass.Text;                                                         //Get the password they entered

            if (File.Exists(appData + "/.locker/pass.txt"))                                        //Make sure pass.txt file exists
            {
                StreamReader sr = new StreamReader(appData + "/.locker/pass.txt");                 //Start reading from pass.txt
                if (input == sr.ReadLine())                                                        //If the given password matches the one on file
                {
                    sr.Close();                                                                    //Stop reading from the file
                    this.Hide();                                                                   //Hide the welcome form
                    LockerView lockerView = new LockerView();                                      //Instance of the LockerView form
                    lockerView.Show();                                                             //Show it
                }
                else//Wrong password
                {
                    label2.ForeColor = Color.Red;                        //Change the color of the label to red
                    label2.Text      = "Incorrect password! Try again."; //change the text
                    sr.Close();                                          //stop reading from the file
                }
            }
            else//The password file doesn't exist. I wonder where it went...
            {
                StreamWriter sw = new StreamWriter(appData + "/.locker/pass.txt");//begin writing to pass.txt
                sw.WriteLine(input);                      //write it to the file
                sw.Close();                               //stop writing to the file
                this.Hide();                              //get rid of this form
                MessageBox.Show("You don't appear to have a password set.\nDid you delete the password file? ( ͡° ͜ʖ ͡°)\n\nDoesn't matter. We've just made the text you inputted your new password.");
                LockerView lockerView = new LockerView(); //create a new instance of the LockerView form
                lockerView.Show();                        //show it
            }
        }
Ejemplo n.º 2
0
 /*Method to create a new locker*/
 private void createLocker()
 {
     if (txtPass.Text != "")                                                                          //Ensure they actually gave us a password
     {
         string       appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); //path to appdata
         StreamWriter sw      = new StreamWriter(appData + "/.locker/pass.txt");                      //begin writing to pass.txt
         string       pass    = txtPass.Text;                                                         //get their chosen password
         sw.WriteLine(pass);                                                                          //write it to the file
         sw.Close();                                                                                  //stop writing to the file
         this.Hide();                                                                                 //get rid of this form
         LockerView lockerView = new LockerView();                                                    //create a new instance of the LockerView form
         lockerView.Show();                                                                           //show it
     }
     else//didn't give a password
     {
         label2.Text      = "Please enter a password!"; //Tell them they really should give us a password
         label2.ForeColor = Color.Red;                  //Turn the text red to really drive home our point
     }
 }