Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 446
Mircea Ispas Avatar asked Jan 10 '12 09:01

Mircea Ispas


2 Answers

This

dialog.Filter = "Image files (*.bmp)|*.bmp;*.jpg"

will only display "Image files (*.bmp)" in the combo box while still showing files with all the specified extensions.

Or you could do

dialog.Filter = "Image files (*.bmp;...)|*.bmp;*.jpg"

to indicate that it looks for files with extension bmp and some other extensions.

This might depend on the OS. I tested with Windows 7.

like image 168
Henrik Avatar answered Oct 14 '22 03:10

Henrik


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();
like image 2
T23 Avatar answered Oct 14 '22 02:10

T23