Hi, i'm trying to validate ATM Username and NIP from a .Text file on my drive. I really don't know how to do it so if any of you got any tips that could help me, that would be great
What I have tried:
***Logon page****
public partial class MainWindow : Window
{
public static GestionnaireGuichet guichet = new GestionnaireGuichet();
public MainWindow()
{
InitializeComponent();
}
int count = 0;
private void button_Click(object sender, RoutedEventArgs e)
{
if (count == 3)
{
this.Close();
}
if ((string.IsNullOrEmpty(user.Text)) || (string.IsNullOrEmpty(pass.Password)))
{
MessageBox.Show("Provide a valide username and password");
}
if ((user.Text.Length > 0) || (pass.Password.Length > 0))
{
OperationCompte operation = new OperationCompte();
this.Close();
operation.Show();
}
else
count++;
}
***Using this for validation***
public bool ValidatePassword(string username, string password)
{
string[] strArray = System.IO.File.ReadAllLines(@"D:\Project\Guichet\Guichet\bin\Debug\client.txt");
if (username != strArray[0]) return false;
if (password != strArray[1]) return false;
if (username == strArray[0] && password == strArray[1]) return true;
else
return false;
}
***I'm using this to read text file***
public bool LireClient()
{
string[] strArray;
StreamReader sr = new StreamReader("client.txt");
string strLine = sr.ReadLine();
while (strLine != null)
{
strArray = strLine.Split(',');
client.Add(new Client(strArray[0], strArray[1]));
strLine = sr.ReadLine();
}
sr.Close();
return true;
}