The OpenFileDialog dialog has a description of the Filter property:
First of all, let's explain an example and analyze the composition of the Filter attribute: "Excel file |*.xls", the previous "Excel file" becomes a label, which is a readable string that can be customized, "|*.xls" is a filter, which means a file with the suffix .xls in the filter folder, and "*" indicates a string that matches the Excel file name.
OK, let's talk about a few situations that we often use:
1. Filter is null or empty, which means all files are displayed and folders are always displayed
2. You need to filter specific files, set the filter attribute to "tag|*. suffix", according to this format, the tag can be customized, it is a string, the suffix indicates the file suffix you need to filter, such as ".txt, . doc", etc
3. You need to filter a variety of files, for example, you need to filter image files, but there are several suffixes of image files, such as jpg, png, gif, etc., when you need to filter these files at the same time, set the Filter attribute to "tag|*.jpg; *.png; *.gif", Note: Just add a few more suffixes to the filter, separated by semicolons
4. When you need to filter multiple files, but list them all at the same time, only when the user selects the required file type through the drop-down list, the filter will be carried out. In this case, you only need to set a few more filters, and the filter attribute is set as follows: "Tag 1|*.jpg|Tag 2|. png|tag3|. gif”。 Note: Use "|" between different filters Just separate them.
The filter attribute is similar to a regular expression, try * to represent the character that matches the file name, use the ". suffix" to match the suffix name of the file, and use the suffix (try; sign separates the required suffix) indicates that all files that match the suffix are filtered at the same time, by "|" Connecting different filters means filtering files by selecting a suffix name by the user
|