[RhinoCommon] SaveFileDialog does not handle Filter correctly

When I run a save file dialog like below, the drop down box of the file type shows erroneous characters, sometimes on many entries.

Rhino.UI.SaveFileDialog d = new Rhino.UI.SaveFileDialog();
d.Filter = "Hydrostatics Report (.lis)|*.lis";

But, if I append a pipe symbol | to the end of the filter, this does not happen. I’m guessing here, but it seems that the system uses C-style string scanning, does not find the final | and keeps going in a buffer overrrun?

Rhino.UI.SaveFileDialog d = new Rhino.UI.SaveFileDialog();
d.Filter = "Hydrostatics Report (.lis)|*.lis|"; // this works, but is not a valid Filter string according to MSDN and does not work in the winforms SaveDialog

If this uses MFC under water, I think the convention there is to use a double null terminated string of null- terminated strings, “stringstring”.

The standard convention for teminating a filter string is to append two pipe characters. Thus, your example would look like this:

"Hydrostatics Report (.lis)|*.lis||"


Rhino.UI.SaveFileDialog d = new Rhino.UI.SaveFileDialog();
d.Filter = "Hydrostatics Report (.lis)|*.lis||";

I’m not sure where the ‘standard convention’ you mention is defined, but it would be nice if you followed the MSDN SaveFileDialog convention (see http://msdn.microsoft.com/en-us/library/system.windows.controls.savefiledialog.filter(v=vs.95).aspx), which does not use a double pipe terminator. If I use such a double pipe terminator on a winforms SaveFileDialog, the result looks like this, with an additional, emtpy, file type.

1 Like

I will add your request to the pile. In the mean time, you might just want to use System.Windows.Forms.SaveFileDialog.

1 Like

SR 5 Will support filter strings ending with “|”, “||” or no “|” at all.

1 Like

It’s great to see that even “old” issues are being followed up. Thanks all :slight_smile:

RH-28815 is fixed in the latest Service Release Candidate