Winform file filter and winform file Filter
In the. net Framework, Microsoft encapsulates an OpenFileDialog dialog box for opening files. This dialog box contains a Filter attribute that can Filter files. This attribute can be used to Filter the files we need.
Therefore, it is necessary to remember the format of the Filter attribute. There are two types of formats:
1 // a filtering item contains multiple formats 2 ofd. filter = "image file (*. gif ;*. png ;*. jpg ;*. bmp ;*. ico) | *. gif ;*. png ;*. jpg ;*. bmp ;*. ico "; 3 // multiple filtering Items 4 ofd. filter = "pdf file (*. pdf) | *. pdf | text file (*. txt) | *. txt ";
Example: If the Filter attribute is set as follows:
1 ofd. filter = "all files (*. *) | *. * "+" | "+ 2" text file (*. txt) | *. txt "+" | "+ 3" pdf file (*. pdf) | *. pdf "+" | "+ 4" office files (*. doc ;*. docx ;*. xls ;*. xlsx ;*. ppt ;*. pptx) | *. doc ;*. docx ;*. xls ;*. xlsx ;*. ppt ;*. pptx "+" | "+ 5" image file (*. gif ;*. png ;*. jpg ;*. jpeg ;*. bmp ;*. ico) | *. gif ;*. png ;*. jpg ;*. jpeg ;*. bmp ;*. ico "+" | "+ 6" audio file (*. mp3 ;*. mid ;*. wav;) | *. mp3 ;*. mid ;*. wav; "+" | "+ 7" video file (*. mp4 ;*. avi ;*. rmvb ;*. wmv ;*. mkv ;*. flv) | *. mp4 ;*. avi ;*. rmvb ;*. wmv ;*. mkv ;*. flv "+" | "+ 8" compressed file (*. rar ;*. zip ;*. 7z) | *. rar ;*. zip ;*. 7z "+" | "+ 9" HTML file (*. htm ;*. html) | *. htm ;*. html "+" | "+ 10" XML file (*. xml ;*. xaml) | *. xml ;*. xaml "+" | "+ 11" code file (*. c ;*. cpp ;*. h ;*. hpp ;*. cs ;*. java) | *. c ;*. cpp ;*. h ;*. hpp ;*. cs ;*. java "+" | "+ 12" program file (*. exe ;*. dll ;*. jar ;*. class) | *. exe ;*. dll ;*. jar ;*. class ";
Article synchronous update: http://www.motyer.cn/Files/BlogDetails/winform-file-filter.html