Select both files and folders using OpenFileDialog

Xtrem picture Xtrem · Sep 17, 2013 · Viewed 10.3k times · Source

I have researched a lot to find a suitable answer to this problem, but I am failing .

I can see multiple questions asked here and on other forums also , but no clear answer that brings a clear solution .

I want OpenFileDialog to select file/files for me as well as allow me to select folders also. eg. a. either Multiple files OR multiple folders (- most Prior) b. combination of Files and Folders (-less Prior)

I figured our similar question here ( so please don't mark it as duplicate )

Question 1 [Answer links are broken]

Question 2 [Question isn't completely asking what my requirements are.]

Please guide me through some solution . I am a novice and a learner.

Any help or pointers would be very helpful .

Thanks.

Answer

Anirudha picture Anirudha · Sep 17, 2013

OpenFileDialog is used to open a file not folder

To allow selection of multiple files set Multiselect property to true.

For selecting Folder it's mentioned in the docs

If you want to give the user the ability to select a folder instead of a file, use FolderBrowserDialog.