Exemplo n.º 1
0
        private void Login_Click(object sender, EventArgs e)
        {
            User = new Profile();
            string folderName    = System.IO.Directory.GetCurrentDirectory();
            string subFolder1    = LoginName.Text + LoginPassword.Text;
            string pathString    = System.IO.Path.Combine(folderName, subFolder1);
            string fileName      = LoginName.Text + ".txt";
            string newPathString = System.IO.Path.Combine(pathString, fileName);

            if (System.IO.Directory.Exists(pathString))
            {
                using (StreamReader reader = new StreamReader(newPathString))
                {
                    User.ProfileName = reader.ReadLine();
                    User.Password    = reader.ReadLine();
                    User.UserName    = reader.ReadLine();
                }
                MyApp.SelectedIndex = 3;
                LoginName.Clear();
                LoginPassword.Clear();
            }
            else
            {
                DialogResult result = MessageBox.Show("This Account Does Not Exist, Do You Wish To Signup?", "Login error", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (result == DialogResult.Yes)
                {
                    MyApp.SelectedIndex = 2;
                }
                LoginName.Clear();
                LoginPassword.Clear();
            }
        }