Search code examples
windowsc++-cliopenfiledialog

Is it possible to have file filters for multiple extension types?


I'm using a standard Windows FileDialog to allow the user to select some files. I'd like to filter out only the file types I'm interested in though (lets call them *.a and *.b). Is there any way to do this without using *.*? I've tried the following but it fails to match any files at all:

this->openFileDialog1->DefaultExt = L"*.a,*.b";
this->openFileDialog1->FileName = L"openFileDialog1";
this->openFileDialog1->Filter = L"My Data Files (*.a,*.b)|*.a,*.b";

Solution

  • You need to use a semicolon:

    this->openFileDialog1->Filter = L"My Data Files (*.a;*.b)|*.a;*.b";