File and Folder Selection DialogBox

Hi,

I want to select file and folder (both at a time) using C#.

please help me

thanks.
LVL 16
Kalpesh ChhatralaSoftware ConsultantAsked:
Who is Participating?
 
d_yorkCommented:
Understood.  By default, the selection of files necessitates the navigation of folders.  Therefore, the user would need to indicate, somehow, that they are wanting to select a folder and not navigate down into it to find a file.  I'm guessing you want this functionality so you would not have to use the (non-inheritable) standard dialog classes for selecting files and folders independently.

For this kind of solution, you probably would want to implement a tree view and fill it with folders and files much like "Windows Explorer" would do.  You would then handle the click event, where double-click would navigate into the folder but ctrl+single click would include the folder in the selection, for example.  https://msdn.microsoft.com/en-us/library/ms171645.aspx may be what you are looking for?  That walk through sounds like what you are looking for.
0
 
Éric MoreauSenior .Net ConsultantCommented:
0
 
d_yorkCommented:
include a "using System.IO" and use Path from it - quick example:

            OpenFileDialog ofd = new OpenFileDialog();
            DialogResult dr = ofd.ShowDialog();
            string filename = "";
            string directory = "";
            if (dr == DialogResult.OK)
            {
                filename = Path.GetFileName(ofd.FileName);
                directory = Path.GetDirectoryName(ofd.FileName);
            }
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
Kalpesh ChhatralaSoftware ConsultantAuthor Commented:
i am familiar with OpenFileDialog  class.

I want to select File and Folder from Dialog box. OpenFileDialog box not allowed to select folder.
0
 
Éric MoreauSenior .Net ConsultantCommented:
I am not sure to understand. The OpenFileDialog let you pick a folder and then a file from that folder no? See the attached image.
OpenFileDialog.PNG
0
 
Kalpesh ChhatralaSoftware ConsultantAuthor Commented:
thanks d_york.

i understand i need to design this type of dialog box.

do you know this type of dialogbox (file and folder select functionality) available in free ?

thanks for reply.
0
 
Éric MoreauSenior .Net ConsultantCommented:
So the file you select is not related to the selected folder. Right?

This is a specific need and you will need to create your own dialog.

I have some code that creates the folders structure in a treeview: http://emoreau.com/Entries/Articles/2006/03/Folders-synchronization-using-the-SystemIO-namespace.aspx
0
 
d_yorkCommented:
I do not know of any free control that provides that functionality.
0
 
Éric MoreauSenior .Net ConsultantCommented:
that suggested comment is not providing a solution for this question!

the solution (building a custom dialog to show folders) is available from https:#40680329
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.