Question Directory Tree

Zexor

Well-known member
Joined
Nov 28, 2008
Messages
520
Programming Experience
3-5
is there a tool that can display the directory tree on a form like a treeview?
 
Yes there is; it's called a TreeView. It's up to you to get the folder names yourself, using the Directory or DirectoryInfo class, and then populate the TreeView. You could inherit the TreeView class and encapsulate that functionality in the class itself if you wanted, or perhaps you may be able to find such a control that someone else has already created.
 
Icons

ok i have manage to display the directory tree on the treeview. how do i get the default icon or custom icon of each folder so it also display on the treeview?

Also, if i want the Desktop as the root node on the treeview, which dir should i start put there? i want the desktop that has libraries, homegroup, computer, network, etc under it.
if i just use Environment.GetFolderPath(Environment.SpecialFolder.Desktop), i wouldnt get any of the ones i listed above and only the folders i have on my desktop. do i need to manually add each?
 
ok i have manage to display the directory tree on the treeview. how do i get the default icon or custom icon of each folder so it also display on the treeview?
You'd have to employ the Windows API for that. Exactly which functions I don't know, but that's not specifically a VB.NET issue so you'd most likely have to look beyond VB.NET-specific resources to find out.
Also, if i want the Desktop as the root node on the treeview, which dir should i start put there? i want the desktop that has libraries, homegroup, computer, network, etc under it.
That's not a folder. The only things that are actually folders in Windows Explorer are the nodes under Computer and their children. Everything else is something that Windows Explorer adds specifically. Windows Explorer itself just contains a TreeView and a ListView that the Windows developers have provided logic to populate, just as you're doing. They have added custom nodes as well as those representing physical folders, just as you can do. Again, you'd have to go beyond pure managed code for that.
 
Back
Top