Marvin kakuru

Marvin kakuru

  • 1.4k
  • 359
  • 160.6k

display foreach loop in textbox

Sep 16 2023 8:13 AM

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<FileInfo> fileList = dir.GetFiles("*.*", SearchOption.AllDirectories);
            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();       

            }

}


Answers (3)