Advertisement
Guest User

Untitled

a guest
Oct 31st, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace Personal_Accounts_Information
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14.  
  15. List<Accounts> users = new List<Accounts>();
  16. //Decides were the .txt file will be saved to.
  17. string path = @"D:\Personal Accounts Information.txt";
  18.  
  19.  
  20. //This will out put all the information that has allready be created in the .txt file to the console so the user
  21. // can see all the information they have saved.
  22. using (StreamReader sr = new StreamReader(path))
  23. {
  24. string line = sr.ReadToEnd();
  25. Console.WriteLine(line);
  26. }
  27. bool willContinue = true;
  28.  
  29. do
  30. {
  31. string accountName;
  32. string userName;
  33. string passWord;
  34.  
  35. Console.WriteLine("Enter your Account Name or type exit to quit program. ");
  36. accountName = Console.ReadLine();
  37.  
  38. if (accountName != "exit")
  39. {
  40.  
  41. Console.WriteLine("Enter your User Name for the " + accountName);
  42. userName = Console.ReadLine();
  43. Console.WriteLine("Enter your Password for the " + userName, "assotied with" + accountName);
  44. passWord = Console.ReadLine();
  45.  
  46. Accounts account = new Accounts(accountName, userName, passWord);
  47. users.Add(account);
  48. }
  49. else
  50. {
  51. willContinue = false;
  52. }
  53.  
  54. } while (willContinue);
  55.  
  56. using (StreamWriter sw = new StreamWriter(path, true))
  57. {
  58. foreach(Accounts accounts in users)
  59. {
  60. Console.WriteLine(" Account Name: " + accounts.accountName + " UserName: " + accounts.username + " Password " + accounts.passWord);
  61.  
  62. sw.WriteLine("Account Name: " + accounts.accountName /*.ToString()*/);
  63. sw.WriteLine("UserName: " + accounts.username /*.ToString()*/ + "\r\n");
  64. sw.WriteLine("Password: " + accounts.passWord /*.ToString()*/ + "\r\n");
  65. }
  66. }
  67.  
  68. }
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement