Answer the question
In order to leave comments, you need to log in
How to check if there is a number in a txt file?
I am making a phone book in C# Windows Forms NET. Unable to check if there is a number in the file. Always says no.
loginUser - text from TextBox
string loginUser = loginField.Text;
string[] numbers = File.ReadAllLines(@"C:\Sharp_text\number2.txt");
if(numbers.Contains(loginUser))
{
MessageBox.Show("Данные уже существуют!");
}
else
{
//File.AppendAllText(@"C:\Sharp_text\number2.txt", loginUser + Environment.NewLine);
MessageBox.Show("Данные успешно добалены");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question