TinKerBell
TinKerBell

Reputation: 2121

Select html files in a folder

Using "folderBrowserDialog1" can i select only HTML files in a folder.

My code is like this :

private void btnBrowse_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");
    }
 }

Upvotes: 0

Views: 1595

Answers (1)

Habib
Habib

Reputation: 223287

Use: DirectoryInfo.GetFiles Method (String)

Returns a file list from the current directory matching the given search pattern.

string[] files = Directory.GetFiles("*.html");

Or if you only want to html files to be available for selection you can use:

OpenFileDialog

folderBrowserDialog1.Filter = "*.html | *.htm";

Upvotes: 5

Related Questions