Search code examples
c#winformsopenfiledialog

Multiple file extensions in OpenFileDialog


How can I use multiple file extensions within one group using OpenFileDialog? I have Filter = "BMP|*.bmp|GIF|*.gif|JPG|*.jpg|PNG|*.png|TIFF|*.tiff" and I want to create groups so JPG are *.jpg and *.jpeg, TIFF are *.tif and *.tiff and also 'All graphic types'? How can I do that?


Solution

  • Try:

    Filter = "BMP|*.bmp|GIF|*.gif|JPG|*.jpg;*.jpeg|PNG|*.png|TIFF|*.tif;*.tiff"
    

    Then do another round of copy/paste of all the extensions (joined together with ; as above) for "All graphics types":

    Filter = "BMP|*.bmp|GIF|*.gif|JPG|*.jpg;*.jpeg|PNG|*.png|TIFF|*.tif;*.tiff|"
           + "All Graphics Types|*.bmp;*.jpg;*.jpeg;*.png;*.tif;*.tiff"