Click here to Skip to main content
15,896,207 members

Comments by phannhatthanh1510 (Top 1 by date)

phannhatthanh1510 4-Jun-19 9:58am View    
Thank you for your idea. I'm using ReadAllLine and can get correct line

Example full-data:
442226082783011 || 444224591985152 || 04/06/2019 ||
367450779076725 || 455122459198567 || 04/06/2019 ||
756504089869778 || 422364058593394 || 04/06/2019 ||
643453064359261 || 943214058593364 || 04/06/2019 ||
735359076240626 || 432311338593159 || 04/06/2019 || Lainraet
365202075218392 || 424324058593073 || 04/06/2019 ||
535675097553486 || 534525059269665 || 04/06/2019 ||
968563087172661 || 423523338795260 || 04/06/2019 ||

Code:
string path = @"E:\Data.txt";
string[] readText = File.ReadAllLines(path);
foreach (string s in readText)
{
richTextBox1.Text += s.ToString();
if ((s.Contains(txtInput.Text) == true))
{
lblOutput.Text = "found";
break;
}
else
{ lblOutput.Text = "Not Found";
}
}

Search: 365202075218392 and output results:
442226082783011 || 444224591985152 || 04/06/2019 ||
367450779076725 || 455122459198567 || 04/06/2019 ||
756504089869778 || 422364058593394 || 04/06/2019 ||
643453064359261 || 943214058593364 || 04/06/2019 ||
735359076240626 || 432311338593159 || 04/06/2019 || Lainraet
365202075218392 || 424324058593073 || 04/06/2019 ||

I want to search and only show the last line: 365202075218392 || 424324058593073 || 04/06/2019 ||
What should I do? please help me