Display only text files openfiledialog
I want to know how to filter out all files that 开发者_Python百科are not txt files in the open dialog in c#. I have been playing with this for ages and had no joy.
Use the filter property: MSDN Filter
Here is a MSDN Walk through on how to Customize OpenFile Dialog
Here is an example:
openFileDialog.Filter = "Text|*.txt|All|*.*";
You can remove All
if you dont want to give them an option to select other types of files:
Can't you use the .Filter property?
http://msdn.microsoft.com/en-us/library/system.windows.forms.filedialog.filter.aspx
Or did i misunderstand you?
OpenFileDialog.Filter
property.
Documentation - MSDN OpenFileDialog Class
精彩评论