NSIS SelectFileDialog filter not being applied

242 views Asked by At

I have used the following line in an NSIS script:

nsDialogs::SelectFileDialog open "C:\temp.rar" "*.rar"

When I run the resultant installer (in Windows 10) the file dialog opens to C: as it should, temp.rar shows in the File name field, and *.rar shows in the filter dropdown. However the filter is not being applied to the file list. That is, all filetypes are still visible, despite *.rar being the only entry in the filter dropdown.

Does anyone have any idea what might be causing this or how to fix it?

1

There are 1 answers

2
Anders On BEST ANSWER

The documentation is unfortunately not clear on this but it uses the same format as the GetOpenFileName function in Windows; the filter is a list of pairs; display string and DOS filter:

nsDialogs::SelectFileDialog open "C:\temp.rar" "*.rar|*.rar"
Pop $0
nsDialogs::SelectFileDialog open "C:\temp.rar" ".rar files|*.rar|All Files|*.*"
Pop $0

Keep in mind that the filter is only there to help the user but the user can type in any file name they want even if it does not match the active filter.