0

I have a file open dialog box that has a three stage filter option of <exact_name>.<ext>, *.<ext>, and 'all files|*.*', and it's working fine.

However we now have a case where we have two variants of <exact_name>.<ext> file, where one is simply a few more characters longer, e.g. <date>_<time>.txt and <date>_<time>_raw.txt.

Unfortunately the previous filter no longer works because the open file dialog presents both versions to the user, leading to possible user confusion, mis-clicking etc.

Is there a method e.g. similar to RegEx, for the setting the file open dialog's filter, e.g. ^<date>_<time>$.txt that will only find the exact match as my first filter in the selection?


[EDIT] That is, are there any extra wild card options beyond the * and ?. I'd forgotten about ? but using it doesn't appear to be a help in this case.

phuclv
  • 37,963
  • 15
  • 156
  • 475
Philip Oakley
  • 13,333
  • 9
  • 48
  • 71

1 Answers1

0

Filters in Windows Open File dialog boxes are only meant to filter on specific file extensions, not anything more specific. Even though you may find a way to hack the Open File dialog to get this to work, it definitely won't be what Windows users are expecting.

Can't you change the file extension to .rawtxt or something like that?

Frederik Slijkerman
  • 6,471
  • 28
  • 39
  • @Frederick, The filters do allow `*` style filtering on both sides of the dot, so I can filter on `_*.` and expect to see all the files for a given date, with other dates filtered out, so that part works. Because the files are generated automatically by another application I'm limited in what I can do, and can't change the extension :- – Philip Oakley Aug 02 '12 at 15:09
  • Similar question answered here: [Regular expression to filter files in OpenFileDialog](http://stackoverflow.com/questions/148642/regular-expression-to-filter-files-in-openfiledialog) – Jacob Seleznev Aug 03 '12 at 01:32
  • Still, I think you shouldn't really *want* this. – Frederik Slijkerman Aug 06 '12 at 09:55
  • @FrederikSlijkerman, We do have definitive use case where there are two file styles e.g. Data.csv and DataTrimmed.csv and at the point where the OpenDialog is called we already know which version style we want, so the filter options are say `DataTrimmed.csv|*.csv|*.*` (i.e. specific file; general file; all files), but the actual dialog box will still show the file `Data.csv` because it is 'inside' the DataTrimmed.csv exact filter, even though we already know we don't want to offer that one, leaving the user to make a mistake in their selection. – Philip Oakley Aug 11 '12 at 19:06