Home How can I avoid showing extensions on one Filter option in OpenFileDialog?
Reply: 0

How can I avoid showing extensions on one Filter option in OpenFileDialog?

user1343
1#
user1343 Published in July 20, 2018, 5:05 am

In addition to a list of supported file formats, I want to have a catch-all of "All Supported Files". I want the extensions to be displayed for the individual formats, but not for the catch-all. I thought this would do it:

    const string OpenFileFilters = "AAA Files (*.aaa)|*.aaa|" +
                           "BBB Files (*.bbb)|*.bbb|" +
                           "CCC Files (*.ccc)|*.ccc|" +
                           "DDD Files (*.ddd)|*.ddd|" +
                           "EEE Files (*.eee)|*.eee|" +
                           "FFF Files (*.fff)|*.fff|" +
                           "GGG Files (*.ggg)|*.ggg|" +
                           "HHH Files (*.hhh)|*.hhh|" +
                           "III Files (*.iii)|*.iii|" +
                           "All Supported Files |*.aaa;*.bbb;*.ccc;*.ddd;*.eee;*.fff;*.ggg;*.hhh;*.iii";

    var dialog = new OpenFileDialog
    {
        InitialDirectory = FileUtilites.ValidateInitialDirectory(initialDirectory),
        Filter = OpenFileFilters,
        FilterIndex = Settings.Default.OpenFileFilter,
        Multiselect = true
    };

    var result = dialog.ShowDialog();

But it gives me this:

Is there some way to specify the Filter string so that it will not include the long list of extensions on that last option?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.308444 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO