Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
Hi,

Could someone tell me (or give me code) so i would know how to populate a tree view with all the directories from the pc?

Here is what i want to do:
On button click, i want to show the user a dialog window where he can choose on where to copy some files...

I hope i am understandable,
Thanks in forward...
Posted

Hi!
You don't need to create your own dialog. .NET does this work for you, simply display a OpenFileDialog through which the user can select files to copy. See the documentation for OpenFileDialog here:

http://msdn.microsoft.com/en-us/library/system.windows.forms.filedialog.aspx[^]

Edit: to open a specific path, show the user a FolderBrowserDialog:

http://msdn.microsoft.com/en-us/library/system.windows.forms.folderbrowserdialog.aspx[^]
 
Share this answer
 
v3
Comments
Xonfused 4-Apr-11 6:13am    
thanks for the reply.
But i am trying the user only to choose the path where the files want to be copied (on which directory), not the files that is needed to be copied. I am actually trying to make my own installation.
BobJanova 4-Apr-11 6:40am    
Check Jonathan's edited solution. I believe FolderBrowserDialog will do what you want.
Xonfused 4-Apr-11 7:19am    
Thanks a LOT..
Did you already have a look at this article: My Explorer In C#[^]
 
Share this answer
 
Comments
johannesnestler 3-Apr-11 16:37pm    
good link to a good article but maybe to much for the OP: He better uses OpenFileDialog or some of the other prebuild dialogs.
Xonfused 4-Apr-11 6:27am    
Thank you for the reply..
I reviewed the article, and to be honest it is a little bit confusing. Also, i don't need all that details, here is what i need:
(as i commented on the other answer, i wanna make a custom installation)
Lets say the user clicks first a button (lets call it browse), a new form appears which contains the tree view with all directories (folders only) and on the right side there is a button confirm.. Well when the user would press the confirm button, i wont the path that the user chose in the tree view to be saved (so the program would know where the files to be copied)...

I am sorry if i am asking for (maybe if this is) an obvious answer, but this is my first 'serious' program, and after a few day nonstop work i am little tired at the end and can't concentrate... :)
(i hope i am understandable)
Wendelius 4-Apr-11 16:03pm    
That's just fine. If you're looking a simple way you utilize the FolderBrowserDialog, then Jonathan's answer is excellent for that purpose :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900