Filter Files from Folder Browser dialoge

  • 21 Views
  • Last Post 3 weeks ago
zabihillah posted this 4 weeks ago

I want to get all items of multiples extensions like xlsx,Docx or more from folder browser dialogue. and save it in a list box.

Thank you in advance!

lucy posted this 3 weeks ago

To add filter to the SaveFileDialog or OpenFileDialog you can write as the following c# code.

using(SaveFileDiaLog sfd = new SaveFileDialog(){Filter = "Doc|*.doc|Docx|*.docx"})
{
   if(sfd.ShowDialog() == DialogResult.OK)
   {
      string fileName = sfd.FileName;
   }
}

You can do the same way for OpenFileDialog

If you want to filter all file you can write

Filter = "All files|*.*"
Close