Search code examples
c#openfiledialog

C# Don't display filter extensions in OpenFileDialog


I have multiple extensions in the Filter property of OpenFileDialog. Is possible to hide the extensions and show only the description?

Sample:

dialog.Filter = "Image files|*.bmp;*.jpg; many image file extensions here"

I want to show only the text: "Image files" in the file type combo box because the extension string is very long. Is this possible?


Solution

  • This should work:

        dialog.Filter = "All Supported Audio | *.mp3; *.wma | MP3s | *.mp3 | WMAs | *.wma";
        dialog.AutoUpgradeEnabled = false; //using FileDialog.AutoUpgradeEnabled = false it will display the old XP sytle dialog box, which then displays correctly
        dialog.ShowDialog();