Exemplo n.º 1
0
        static void textFile()
        {
            string fileName = Directory.GetCurrentDirectory() + "\\hashedAccounts.txt";

            try
            {
                // Check if file already exists. If yes, delete it.
                if (!File.Exists(fileName))
                {
                    FileStream fs = File.Create(fileName);
                    fs.Close();
                }

                // Open the stream and read it back.
                using (StreamReader sr = File.OpenText(fileName))
                {
                    string[] lines = File.ReadAllLines(fileName);
                    for (int i = 0; i < lines.Length; i++)
                    {
                        Account populateUser = new Account();
                        populateUser.Username = lines[i];
                        populateUser.Password = lines[++i];
                        AccountList.ExistingAccount(populateUser);
                    }
                }
            }
            catch (Exception Ex)
            {
                Console.WriteLine(Ex.ToString());
            }
        }
Exemplo n.º 2
0
        static Account CreateAccount()
        {
            Account NewUser = new Account();

            Console.WriteLine("Enter new username:"******"Account Exists\n Please enter a new username\n");
                    exists = true;
                }
                else
                {
                    exists = false;
                }
            } while (exists == true);
            Console.WriteLine("Enter Password:"******"Enter Password Again");
            string secondinput = "";

            do
            {
                secondinput = Console.ReadLine();
                if (secondinput != firstinput)
                {
                    Console.WriteLine("Passwords do not match.\n");
                }
            } while (secondinput != firstinput);

            NewUser.Password = secondinput;
            AccountList.AddAccount(NewUser);
            return(NewUser);
        }