c# - How to filter *.abc from *.abcd files when using OpenFileDialog? -


i have created openfiledialog object, called openfiledialog.

when calling openfiledialog.showdialog want able select files having extension ".abc" , not ".abcd".

using property:

this.openfiledialog.filter = "*.abc"; 

does not work. ".abcd" files can selected.

here full code:

var openfiledialog = getopenfiledialog("abc",                                        "*.abc",                                        "anything (*.abc)|*.abc",                                        "select abc file import...");  if (openfiledialog.showdialog() == dialogresult.ok) { dojob(); }           

where getopenfiledialog is:

private openfiledialog getopenfiledialog(string defaultext, string filename, string filter, string title)     {         return new openfiledialog             {                 defaultext = defaultext,                 filename = filename,                 filter = filter,                 title = title,             };     } 

i appreciate help. thanks!

use filter option of openfiledialog

this.openfiledialog.filter = "abc files (*.abc)|*.abc" 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -