Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display only text files openfiledialog

Tags:

c#

I want to know how to filter out all files that are not txt files in the open dialog in c#. I have been playing with this for ages and had no joy.

like image 389
JohnB Avatar asked Mar 02 '26 05:03

JohnB


1 Answers

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:

like image 157
Nix Avatar answered Mar 04 '26 18:03

Nix



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!