Hi Guys
am trying to view for each loop values in a multi line textbox but am still failing, below is my code
any help?
}
DirectoryInfo dir = new DirectoryInfo(startFolder);
IEnumerable
string searchTerm = "the";
var queryMatchingFiles =
from file in fileList
where file.Extension == ".pdf"
let fileText = GetFileText(file.FullName)
where fileText.Contains(searchTerm)
select file.FullName;
//Console.WriteLine("The term \"{0}\" was found in:", searchTerm);
textBox2.Text = "The term \"{0}\" was found in:";
foreach (string filename in queryMatchingFiles)
{
//Console.WriteLine(filename);
textBox2.Text += filename.ToString();
}
}

Tahir AnsariPosted Sep 16, 2023, 8:42 AM
Saravanan GanesanPosted Sep 24, 2023, 5:15 PM
To display the filenames found in the multi-line TextBox, you should use the
AppendTextmethod instead of setting theTextproperty directly. Modify your loop as follows:foreach (string filename in queryMatchingFiles)
{
textBox2.AppendText(filename + Environment.NewLine);
}
This appends each filename to the existing text in the TextBox with proper line breaks.
Marvin kakuruPosted Sep 16, 2023, 8:53 AM
Tahir thanks a lot, AppendText has worked perfectly.
thanks again