Sunday, 29 September 2013

method wont check file for matching string

method wont check file for matching string

here is the code:
public bool checkUsernameNotExist()
{
var userNames = File.ReadAllLines(@"C:\Other\myFile.txt");
if (userNames.Contains(userNameBox.Text))
{
MessageBox.Show("Sorry, that user name is not available, try
again", "Invalid Username Entry");
userNameBox.Text = "";
passwordBox.Text = "";
repeatPasswordBox.Text = "";
return false;
}
else
return true;
}
This should check if a username already exists in the text file, but it
allows me to register anyway?

No comments:

Post a Comment