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 Opdracht16_Reader
- {
- class Program
- {
- static void Main(string[] args)
- {
- newTry();
- }
- public static void newTry()
- {
- string usernameIncorrect = "";
- string passwordIncorrect = "";
- string username = "";
- string password = "";
- string filePCat = @"C:\myProgrammeerFiles\Opdracht1.6-file.txt";
- string filePUser = @"C:\myProgrammeerFiles\username.txt";
- string filepathPass = @"C:\myProgrammeerFiles\password.txt";
- // open username bestand en sla regel op in variabel
- StreamReader readerUser = File.OpenText(filePUser);
- username = readerUser.ReadLine();
- // open password bestand en sla regel op in variabel
- StreamReader readerPass = File.OpenText(filepathPass);
- password = readerPass.ReadLine();
- // open cat bestand en sla regel op in variabel
- StreamReader readerCat = File.OpenText(filePCat);
- // Sluit het bestand
- readerUser.Close();
- readerPass.Close();
- readerCat.Close();
- // Laat de user de naam en wachtwoord inputten via console en check of in/correct is
- while (usernameIncorrect != username)
- {
- Console.WriteLine("Vul uw username in:");
- usernameIncorrect = Convert.ToString(Console.ReadLine());
- Console.WriteLine("Vul uw password in:");
- passwordIncorrect = Convert.ToString(Console.ReadLine());
- if (usernameIncorrect != username && passwordIncorrect != password)
- {
- Console.WriteLine("Credentials incorrect!");
- Console.WriteLine("Wil je het opnieuw proberen Ja of Nee?");
- string answer = Console.ReadLine();
- if (answer == "ja")
- {
- newTry();
- }
- else
- {
- Environment.Exit(0);
- }
- }
- else if (usernameIncorrect == username && passwordIncorrect == password)
- {
- Console.WriteLine("correct");
- Console.WriteLine("Je bent ingelogd");
- //kat laten zien
- string[] readText = File.ReadAllLines(filePCat);
- foreach (string s in readText)
- {
- Console.WriteLine(s);
- };
- }
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement