Tuesday, 1 October 2013

C# Returning string lines that only contain listbox items

C# Returning string lines that only contain listbox items

I am trying to retrieve lines of data from a text file that contain items
I added to a listbox, but it just keeps returning all lines of data from
my test file:
foreach (var item in searchValList.Items)
{
while ((line = file.ReadLine()) != null)
{
if (line.Contains(searchValList.Text))
{
sb.AppendLine(line.ToString());
resultsTextBox.Text = sb.ToString();
}
else
{
resultsTextBox.Text = "The value was not found in this file";
}
}
}

No comments:

Post a Comment