Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

visual studio - Excluding file extensions from open file dialog in C#

I am trying to put a filter on my C# openFileDialog that excludes certain file extensions. For example I want it to show all files in a directory that are not .txt files.

Is there a way to do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I don't think this is possible. The way the filter is set up, is that you can choose which files to show, but I don't think there's a way to show "All files except...". Come to think of it, have you ever seen an Open File Dialog in Windows that has this? I don't think I've ever seen one.

Your best bet is to let them choose all files, and then prompt the user if they select one that isn't allowed OR filter it down to all the possible files that you can deal with.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...