Advertisement
Guest User

Untitled

a guest
Oct 30th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.59 KB | None | 0 0
  1. class Program
  2.     {
  3.         static void Main(string[] args)
  4.         {
  5.          
  6.             List<Account> users = new List<Account>();
  7.             string path = @"D:\C#\myAccounts.txt";
  8.             string userName;
  9.             string password;
  10.  
  11.             using (StreamReader sr = new StreamReader(path))
  12.             {
  13.                 string line = sr.ReadToEnd();
  14.                 Console.WriteLine(line);
  15.               //  List<string> ReadFile = File.ReadAllLines(@"C:\TEMP\FILE.TXT").ToList();
  16.                
  17.             }
  18.  
  19.             bool willContinue = true;
  20.  
  21.             do
  22.             {
  23.                 Console.WriteLine("Enter your username or type exit to quit");
  24.                 userName = Console.ReadLine();
  25.  
  26.                 // if the user types
  27.                 if (userName != "exit"){
  28.                     Console.WriteLine("Enter your password:");
  29.  
  30.                     password = Console.ReadLine();          
  31.  
  32.                     Account account = new Account(userName,password);
  33.  
  34.                     users.Add(account);
  35.                 }
  36.                 else{
  37.                     willContinue;
  38.                 }
  39.             } while (willContinue);
  40.  
  41.             foreach (Account account in users)
  42.             {
  43.                 Console.WriteLine(" Username: " + account.userName + " Password: " + account.passWord);
  44.                 File.AppendAllText(path," Username: " + account.userName.ToString() + "\r\n" + " Password: " + account.passWord.ToString() + "\r\n");
  45.                          
  46.             }
  47.  
  48.             Console.ReadLine();
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement