Advertisement
Guest User

Untitled

a guest
Oct 10th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.41 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7.  
  8. namespace ConsoleApplication1 //Change this text to whater ur project is called
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. string Firstname, Lastname, age, Username, password,Start; //creates the different variables
  15. int next2;
  16. bool next1;
  17. next1 = false;
  18. next2 = 0;
  19. do
  20. {
  21. Console.Clear();
  22. Console.WriteLine("Would you like to 'create' an account or 'login'");
  23. Start = Console.ReadLine();
  24. if (Start == "create")
  25. {
  26. next1 = true;
  27. next2 = 1;
  28. }
  29. if (Start == "login")
  30. {
  31. next1 = true;
  32. next2 = 2;
  33. }
  34. if (Start == "Create")
  35. {
  36. next1 = true;
  37. next2 = 1;
  38. }
  39. if (Start == "Login")
  40. {
  41. next1 = true;
  42. next2 = 2;
  43. }
  44. } while (next1 == false);
  45.  
  46. if (next2 == 1) //Account Creation
  47. {
  48. Console.Clear();
  49. Console.WriteLine("Enter Your firstname"); //Firstname
  50. Firstname = Console.ReadLine();
  51. Console.Clear();
  52.  
  53. Console.WriteLine("Enter Your Lastname"); //Second name
  54. Lastname = Console.ReadLine();
  55. Console.Clear();
  56.  
  57. Console.WriteLine("Enter Your age"); //Age
  58. age = Console.ReadLine();
  59. Console.Clear();
  60.  
  61. Console.WriteLine("Enter Your password"); //Password
  62. password = Console.ReadLine();
  63. Console.Clear();
  64.  
  65. Username = Firstname + age; //Creates UserName
  66. Console.WriteLine("Your Username is: " + Username);
  67. Console.WriteLine("Your password is: " + password);
  68. Console.ReadLine();
  69.  
  70. try //This Part Creates a textfile for the different things
  71. {
  72. StreamWriter sw = new StreamWriter(Username + ".txt"); //One for the password
  73. sw.WriteLine(password);
  74. sw.Close();
  75. }
  76. catch (Exception e)
  77. {
  78. Console.WriteLine("Exception: " + e.Message);
  79. }
  80. finally
  81. {
  82. Console.WriteLine("Executing finally block.");
  83. }
  84. Console.Clear();
  85.  
  86. try//Text file for first name
  87. {
  88. StreamWriter sw = new StreamWriter(Username + "FirstName.txt");
  89. sw.WriteLine(Firstname);
  90. sw.Close();
  91. }
  92. catch (Exception e)
  93. {
  94. Console.WriteLine("Eception: " + e.Message);
  95. }
  96. finally
  97. {
  98. Console.WriteLine("Executing");
  99. }
  100.  
  101. try//Text file for second name
  102. {
  103. StreamWriter sw = new StreamWriter(Username + "SecondName.txt");
  104. sw.WriteLine(Lastname);
  105. sw.Close();
  106. }
  107. catch (Exception e)
  108. {
  109. Console.WriteLine("Eception: " + e.Message);
  110. }
  111. finally
  112. {
  113. Console.WriteLine("Executing");
  114. }
  115.  
  116. try//Text file for first name
  117. {
  118. StreamWriter sw = new StreamWriter(Username + "Age.txt");
  119. sw.WriteLine(age);
  120. sw.Close();
  121. }
  122. catch (Exception e)
  123. {
  124. Console.WriteLine("Eception: " + e.Message);
  125. }
  126. finally
  127. {
  128. Console.WriteLine("Executing");
  129. }
  130.  
  131. next2 = 2;
  132. }//End of creating account
  133.  
  134. if (next2 == 2)
  135. {
  136.  
  137. string inputusername, Filename;
  138. bool verification;
  139. verification = false;
  140. do
  141. {
  142. Console.Clear();
  143. Console.WriteLine("Enter Your username");
  144. inputusername = Console.ReadLine();
  145. Filename = inputusername + ".txt";
  146. if (System.IO.File.Exists(Filename) == true);
  147. {
  148. Console.Clear();
  149. verification = true;
  150.  
  151. }
  152. if (System.IO.File.Exists(Filename) == false);
  153. {
  154. Console.Clear();
  155. Console.WriteLine("Incorrect Username: " + Filename);
  156. Console.ReadLine();
  157.  
  158. }
  159. } while (verification == true);
  160. Console.WriteLine("Congrats");
  161. }
  162.  
  163. }
  164. }
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement