private void button1_Click(object sender, EventArgs e) { DialogResult result = folderBrowserDialog1.ShowDialog(); if (result == DialogResult.OK) { string[] files = Directory.GetFiles(folderBrowserDialog1.SelectedPath); MessageBox.Show("Files found: " + files.Length.ToString(), "Message"); } } This counts number of files in folder. But I need count for only specific files which are in folder such a .txt or .mp3