I am using following code which is displaying all files in listbox. But only files with specified extension selected from combobox(i.e .txt or .html....) should be displayed
private void button1_Click(object sender, EventArgs e)
{
string search = textBox1.Text;
string folder = textBox2.Text;
MessageBox.Show(comboBox1);
string[] allFiles = System.IO.Directory.GetFiles(folder, "comboBox1");//Change path to yours
foreach (string file in allFiles)
{
// MessageBox.Show(allFiles[0]);
var word = File.ReadAllText(file);
//Console.WriteLine(word);
//Console.ReadKey();
if (word.Contains(search))
{
listBox1.Items.Add("Match Found : " + file);
//MessageBox.Show("Match Found : " + file);
}
else
listBox1.Items.Add("Match NOT Found : " + file);
}