Filter Files from Folder Browser dialoge

  • 190 Views
  • Last Post 04 August 2019
zabihillah posted this 01 August 2019

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 04 August 2019

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