Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select both files and folders using OpenFileDialog

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.

like image 274
B Bhatnagar Avatar asked Sep 17 '13 05:09

B Bhatnagar


2 Answers

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.

like image 136
Anirudha Avatar answered Sep 17 '22 04:09

Anirudha


You can't select folder with OpenFileDialog as well as you can't select files with FolderBrowserDialog. But there is an open source control for .net which allows you to select both files and folders you can check it here : OpenFileOrFolderDialog

like image 32
Kurubaran Avatar answered Sep 18 '22 04:09

Kurubaran