7

Is it possible to use the OpenFileDialog class select a file OR folder? It appears only to allow the selection of a file, if you select a folder and then choose open it will navigate to that folder.

If the OpenFileDialog can not be used for this is there another object I should be using?

EDIT: The scenario is that I have a tool that can upload one...many files or folders. I need to be able to provide a dialog like the OpenFileDialog that allows a user to select a file, folder, or a combination of. I know about the FolderBrowseDialog and that is not the answer in this case.

Eric Schoonover
  • 47,184
  • 49
  • 157
  • 202
  • Take a look at the **[Ookii Dialogs](https://github.com/ookii-dialogs)** libraries which have an implementation of a folder browser dialog for Windows Forms and WPF respectively. – C. Augusto Proiete Oct 20 '18 at 21:30

6 Answers6

5

This is the solution I have been looking for, this article provides code and describes how to create a dialog that meets my needs.

CodeProject: Full Implementation of IShellBrowser

Eric Schoonover
  • 47,184
  • 49
  • 157
  • 202
2

Yes, you can use OpenFileDialog to select a folder. Here is an article in CodeProject that demonstrated a way to do it (http://www.codeproject.com/KB/dialog/OpenFileOrFolderDialog.aspx).

stankovski
  • 2,129
  • 2
  • 16
  • 11
0

In my experience in .NET, I would have to say no, sorry for the negative and short answer, but I really don't think there is

johnc
  • 39,385
  • 37
  • 101
  • 139
0

If you have time, you can create your own pretty easily by using the System.Windows.Forms.TreeView Class. Each node can have a checkbox, so If you populate the treeview (onexpand) you can let the user select the files/directories he wants to upload.

This should get you started on populating the treeview with directories, the job to also add files in the treeview should not be that hard:

http://www.java2s.com/Tutorial/VB/0280__GUI-Applications/FileTreeview.htm

Espo
  • 41,399
  • 21
  • 132
  • 159
0

No: the OpenFileDialog is just for opening files. Anyway there is a FolderBrowserDialog you can use for that.

[Edit] Answered too fast: the Edit from the questioner was afterwards.

MADMap
  • 3,132
  • 3
  • 25
  • 31
  • 1
    From the question: "I know about the FolderBrowseDialog and tha is not the answer in this case." – Espo Sep 19 '08 at 07:54
0

I'd suggest taking a look at the Ookii Dialogs libraries which have an implementation of a folder browser dialog for Windows Forms and WPF respectively:

Ookii Folder Browser dialog on Windows 10

Ookii.Dialogs.Wpf

https://github.com/augustoproiete/ookii-dialogs-wpf


Ookii.Dialogs.WinForms

https://github.com/augustoproiete/ookii-dialogs-winforms

C. Augusto Proiete
  • 24,684
  • 2
  • 63
  • 91