I am trying to create a login method that checks a text file called accounts.txt that has a string such as "Bob password" already logged in it. The parameters, "login" being command, "Bob" being param1 and "password" being param2
When I run command line arguments, an example would be "login Bob password" the check should read contents of the file line by line until it finds a match and returns "login Bob successful" otherwise say "invaild username/password"
Not sure how to go about this, any tips are appreciated
protected void login(string command, string param1, string param2) // string command "login" string username, string password
{
// login command
// Needs to check accounts.txt file for username and password.
// if username and password exists, provide logon message
// if username and/ or password does not exist, provide failed logon message.
// IN MEMORY store current login username and password
//checks accounts.txt file if username already exists and if there is a match
if (not sure what arg would go here)
{
string path = "C:\\Files\\accounts.txt";
Console.WriteLine("username and password match", path);
}
else
{
Console.WriteLine("Login Failed: invaild username or password");
string path2 = "C:\\Files\\audit.txt";
using (StreamWriter sw2 = File.AppendText(path2))
{
sw2.WriteLine("Login Failed: Invaild username or password");
}
throw new FileNotFoundException();
}
}
Aucun commentaire:
Enregistrer un commentaire