You call ShowDialog and then use folderBrowserDialog1.SelectedPath property.
You didn't handle the canceling - you're just going as if everything is fine. Every time you call ShowDialog on anything, you should process dialog result and work depending on that result.
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) {
totalfolderfileCount = System.IO.Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*").Length;
string[] array = Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*.bdf*");
txtInputPath.Text = folderBrowserDialog1.SelectedPath;
}
If this helps, please take time to accept the solution so that others may find it. Thank you.