Multiple file extensions in OpenFileDialog

前端 未结 3 1233
失恋的感觉
失恋的感觉 2021-01-30 11:54

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\" a

相关标签:
3条回答
  • 2021-01-30 12:30

    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"
    
    0 讨论(0)
  • 2021-01-30 12:32

    This is from MSDN sample:

    (*.bmp, *.jpg)|*.bmp;*.jpg
    

    So for your case

    openFileDialog1.Filter = "JPG (*.jpg,*.jpeg)|*.jpg;*.jpeg|TIFF (*.tif,*.tiff)|*.tif;*.tiff"
    
    0 讨论(0)
  • 2021-01-30 12:55

    Based on First answer here is the complete image selection options:

    Filter = @"|All Image Files|*.BMP;*.bmp;*.JPG;*.JPEG*.jpg;*.jpeg;*.PNG;*.png;*.GIF;*.gif;*.tif;*.tiff;*.ico;*.ICO
               |PNG|*.PNG;*.png
               |JPEG|*.JPG;*.JPEG*.jpg;*.jpeg
               |Bitmap(.BMP,.bmp)|*.BMP;*.bmp                                    
               |GIF|*.GIF;*.gif
               |TIF|*.tif;*.tiff
               |ICO|*.ico;*.ICO";
    
    0 讨论(0)
提交回复
热议问题