Search code examples
windowsfilenamesopenfiledialog

Windows OpenFileDialog with more than one file type


I want to open a Windows OpenFileDialog with two possible selections:

foo*bar.xml
*.xml

The file name wildcard is specified with the FileName property but it applies to every file selection specified with the Filter property.

With the Filter property, users can select more than one set of file types, but is there a way to specify different file names in one dialog?

Paul


Solution

  • The file name wildcard is specified with the FileName property

    That doesn't work, only the Filter property can be used to filter files. Furthermore, a wildcard like foo*bar.xml does do what you hope it does, anything past the * is ignored. A wildcard doesn't behave like a regular expression at all. This goes way, way back to early operating systems that didn't have the horsepower to implement regex. Definitely at CP/M, probably as far back as RSX.

    Options are very limited, you can specify multiple wildcards by separating them with a ; semicolon. Like "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*". But that's as far as you can push it.