@bossotron13/

SkybluePeriodicUsername

C#

No description

fork
loading
Files
  • main.cs
  • LoginInfo.Info
  • main.exe
main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.IO;


class MainClass {
  
  public static void Register(){
    Console.Clear();
    Console.Write("Create Username: ");
    string regU = Console.ReadLine();
    Console.Write("Create Password: ");
    string regP = Console.ReadLine();
    Console.Write("Confirm Password: ");
    string regPC = Console.ReadLine();
    if(regP == regPC){
      StreamWriter wr = File.AppendText("LoginInfo.Info");
      wr.WriteLine(regU + "~" + regP);
      wr.Close();
    }else{
      Console.WriteLine("Error Password doesnt match");
      }
    Console.Clear();
    Console.WriteLine("Account created");
  }
  
  public static void Main (string[] args) {
    string inputU;
    string line;
    string inputP;
    string inputLR;
    bool logged = false;
    try{
      StreamReader rd = new StreamReader("LoginInfo.Info");
      rd.Close();
    }catch{
      StreamWriter rd = new StreamWriter("LoginInfo.Info");
      rd.Close();
    }
    
    Console.Clear();
    Console.Write("Login or Register: ");
    inputLR = Console.ReadLine();
    if (inputLR.ToLower() == "register"){
      Register();
    }
    Console.Clear();
    Console.Write("Enter Username: ");
    inputU = Console.ReadLine();
    Console.Write("Enter Password: ");
    inputP = Console.ReadLine();
    System.Threading.Thread.Sleep(2000);
    Console.Clear();
    StreamReader rda = new StreamReader("LoginInfo.Info");
    while((line = rda.ReadLine())!= null)
    {
      string[] result = line.Split("~");
      if (result[0] == inputU){
        if (result[1] == inputP){
          Console.WriteLine("Done");
          logged = true;
        }
      }
    }
    if(logged == false){
      Console.WriteLine("Error");
    }
  }
    
    
  }