Hi all i have writen a bit of code here to read a line of text from a text file and display it depending on what the user searches for which is taken from a text box.
but it will only read one line it will not display all the records that have the word input from the text box what am missing.
private void btnSearch_Click(object sender, EventArgs e)
{
{
string searchText = (txtSearchBirthMonth.Text);
string file = @"C:\Users\michael\Documents\data.txt ";//path to text file
StreamReader reader = new StreamReader(file); string line = null;
foreach (string record in reader.ReadLine().Split('|'))
{
while ((line = reader.ReadLine()) != null)
{
if (Regex.IsMatch(line, searchText, RegexOptions.IgnoreCase))
{
rtbRecord.Text = line;
}
}
}
}
}