Setting the filter to an OpenFileDialog to allow the typical image formats?

前端 未结 11 1047
陌清茗
陌清茗 2020-12-22 16:07

I have this code, how can I allow it to accept all typical image formats? PNG, JPEG, JPG, GIF?

Here\'s what I have so far:

public void EncryptFile()
         


        
11条回答
  •  北荒
    北荒 (楼主)
    2020-12-22 16:35

    In order to match a list of different categories of file, you can use the filter like this:

            var dlg = new Microsoft.Win32.OpenFileDialog()
            {
                DefaultExt = ".xlsx",
                Filter = "Excel Files (*.xls, *.xlsx)|*.xls;*.xlsx|CSV Files (*.csv)|*.csv"
            };
    

提交回复
热议问题