[Solved] OpenFileDialog Filter

Answered
0
0

Hi

When setting a string value to Wisej Open FileDialog “Filter” property, it does not get reflected in the FileDialog when it is launched.

var webOpenFileDialog = new OpenFileDialog
{
Multiselect = true,
Title = “Select Files”,
CheckFileExists = false
};

webOpenFileDialog.Filter = files; // files is a ; separated string values that were generated from a list.

I can see the value being set to Filter while debugging the code, but it does not reflect in the OpenFileDialog.

 

Thanks

praveena

 

  • You must to post comments
Great Answer
0
0

I figured out the issue why the filter was not getting applied. So in the filter property -$”Files ({files})| {files}”,  the space after the vertical bar was causing the issue.

Removing the space helped in showing the filtered files.

 

thanks

praveena

 

  • You must to post comments
0
0

Hi Luca

Thanks for the reply. By files I meant its a string value with different filetypes that are semicolon separated.

So for instance

files = “*.jpeg;*.jpg; //this is generated from a list of filetype values selected by the user.

and if I use this for applying the filter like

webOpenFileDialog.Filter = $”Files ({files})| {files}”;

I can see the dialog displays the value in the dialog as shown in the attached image.

But when i select a folder to select files, it does not display any files at all. Neither it shows based on the filter nor it displays all the files.

thanks

praveena

 

 

Attachment
  • You must to post comments
0
0

Filter is not a list of files. It’s the list of file types. See https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.filedialog.filter?view=net-5.0.

If there is still an issue please send a test case.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.