Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace ConsoleApplication1 //Change this text to whater ur project is called
- {
- class Program
- {
- static void Main(string[] args)
- {
- string Firstname, Lastname, age, Username, password,Start; //creates the different variables
- int next2;
- bool next1;
- next1 = false;
- next2 = 0;
- do
- {
- Console.Clear();
- Console.WriteLine("Would you like to 'create' an account or 'login'");
- Start = Console.ReadLine();
- if (Start == "create")
- {
- next1 = true;
- next2 = 1;
- }
- if (Start == "login")
- {
- next1 = true;
- next2 = 2;
- }
- if (Start == "Create")
- {
- next1 = true;
- next2 = 1;
- }
- if (Start == "Login")
- {
- next1 = true;
- next2 = 2;
- }
- } while (next1 == false);
- if (next2 == 1) //Account Creation
- {
- Console.Clear();
- Console.WriteLine("Enter Your firstname"); //Firstname
- Firstname = Console.ReadLine();
- Console.Clear();
- Console.WriteLine("Enter Your Lastname"); //Second name
- Lastname = Console.ReadLine();
- Console.Clear();
- Console.WriteLine("Enter Your age"); //Age
- age = Console.ReadLine();
- Console.Clear();
- Console.WriteLine("Enter Your password"); //Password
- password = Console.ReadLine();
- Console.Clear();
- Username = Firstname + age; //Creates UserName
- Console.WriteLine("Your Username is: " + Username);
- Console.WriteLine("Your password is: " + password);
- Console.ReadLine();
- try //This Part Creates a textfile for the different things
- {
- StreamWriter sw = new StreamWriter(Username + ".txt"); //One for the password
- sw.WriteLine(password);
- sw.Close();
- }
- catch (Exception e)
- {
- Console.WriteLine("Exception: " + e.Message);
- }
- finally
- {
- Console.WriteLine("Executing finally block.");
- }
- Console.Clear();
- try//Text file for first name
- {
- StreamWriter sw = new StreamWriter(Username + "FirstName.txt");
- sw.WriteLine(Firstname);
- sw.Close();
- }
- catch (Exception e)
- {
- Console.WriteLine("Eception: " + e.Message);
- }
- finally
- {
- Console.WriteLine("Executing");
- }
- try//Text file for second name
- {
- StreamWriter sw = new StreamWriter(Username + "SecondName.txt");
- sw.WriteLine(Lastname);
- sw.Close();
- }
- catch (Exception e)
- {
- Console.WriteLine("Eception: " + e.Message);
- }
- finally
- {
- Console.WriteLine("Executing");
- }
- try//Text file for first name
- {
- StreamWriter sw = new StreamWriter(Username + "Age.txt");
- sw.WriteLine(age);
- sw.Close();
- }
- catch (Exception e)
- {
- Console.WriteLine("Eception: " + e.Message);
- }
- finally
- {
- Console.WriteLine("Executing");
- }
- next2 = 2;
- }//End of creating account
- if (next2 == 2)
- {
- string inputusername, Filename;
- bool verification;
- verification = false;
- do
- {
- Console.Clear();
- Console.WriteLine("Enter Your username");
- inputusername = Console.ReadLine();
- Filename = inputusername + ".txt";
- if (System.IO.File.Exists(Filename) == true);
- {
- Console.Clear();
- verification = true;
- }
- if (System.IO.File.Exists(Filename) == false);
- {
- Console.Clear();
- Console.WriteLine("Incorrect Username: " + Filename);
- Console.ReadLine();
- }
- } while (verification == true);
- Console.WriteLine("Congrats");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement