In my SaveFileDialog I have multiple types in the filter, however when viewing the dialog if I choose a filter to view files of that type in the directory I am only able to see files for the first and last filters.
bool save; SaveFileDialog dlg = new SaveFileDialog(); dlg.FileName = "*"; dlg.DefaultExt = "bmp"; dlg.ValidateNames = true; dlg.Filter = "Bitmap Image (.bmp)|*.bmp|Gif Image (.gif)|*.gif |JPEG Image (.jpeg)|*.jpeg |Png Image (.png)|*.png |Tiff Image (.tiff)|*.tiff |Wmf Image (.wmf)|*.wmf"; save = (bool)dlg.ShowDialog(); if (save) { SaveImage(dlg.FileName); }
I can see files of type .bmp and .wmf If I change the order of the filters I can always only see the first and last.
Remove the spaces after the file type:
dlg.Filter = "Bitmap Image (.bmp)|*.bmp|Gif Image (.gif)|*.gif|JPEG Image (.jpeg)|*.jpeg|Png Image (.png)|*.png|Tiff Image (.tiff)|*.tiff|Wmf Image (.wmf)|*.wmf";
FilterIndex
... DefaultExt is used just during a save. An index is 1-based so if you want to choose the 2nd option then:
dlg.FilterIndex = 2;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With