我正在尝试从包含我添加到列表框中的项目的文本文件中检索数据行,但它只是不断从我的测试文件中返回所有数据行:
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";
}
}
}