Advertisement
Guest User

Untitled

a guest
Feb 14th, 2020
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 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 Opdracht16_Reader
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. newTry();
  15. }
  16. public static void newTry()
  17. {
  18. string usernameIncorrect = "";
  19. string passwordIncorrect = "";
  20. string username = "";
  21. string password = "";
  22. string filePCat = @"C:\myProgrammeerFiles\Opdracht1.6-file.txt";
  23. string filePUser = @"C:\myProgrammeerFiles\username.txt";
  24. string filepathPass = @"C:\myProgrammeerFiles\password.txt";
  25.  
  26. // open username bestand en sla regel op in variabel
  27. StreamReader readerUser = File.OpenText(filePUser);
  28. username = readerUser.ReadLine();
  29.  
  30. // open password bestand en sla regel op in variabel
  31. StreamReader readerPass = File.OpenText(filepathPass);
  32. password = readerPass.ReadLine();
  33.  
  34. // open cat bestand en sla regel op in variabel
  35. StreamReader readerCat = File.OpenText(filePCat);
  36.  
  37.  
  38. // Sluit het bestand
  39. readerUser.Close();
  40. readerPass.Close();
  41. readerCat.Close();
  42.  
  43.  
  44.  
  45. // Laat de user de naam en wachtwoord inputten via console en check of in/correct is
  46. while (usernameIncorrect != username)
  47. {
  48.  
  49.  
  50. Console.WriteLine("Vul uw username in:");
  51. usernameIncorrect = Convert.ToString(Console.ReadLine());
  52.  
  53. Console.WriteLine("Vul uw password in:");
  54. passwordIncorrect = Convert.ToString(Console.ReadLine());
  55.  
  56. if (usernameIncorrect != username && passwordIncorrect != password)
  57. {
  58. Console.WriteLine("Credentials incorrect!");
  59. Console.WriteLine("Wil je het opnieuw proberen Ja of Nee?");
  60.  
  61.  
  62. string answer = Console.ReadLine();
  63.  
  64. if (answer == "ja")
  65. {
  66. newTry();
  67. }
  68. else
  69. {
  70. Environment.Exit(0);
  71. }
  72. }
  73. else if (usernameIncorrect == username && passwordIncorrect == password)
  74. {
  75. Console.WriteLine("correct");
  76. Console.WriteLine("Je bent ingelogd");
  77.  
  78. //kat laten zien
  79. string[] readText = File.ReadAllLines(filePCat);
  80. foreach (string s in readText)
  81. {
  82. Console.WriteLine(s);
  83. };
  84. }
  85.  
  86. }
  87. Console.ReadLine();
  88. }
  89.  
  90. }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement