nd54 Posted June 18, 2003 Posted June 18, 2003 I am trying to get all sub directorys, and load them into a treeview. its only getting the first subdirectory. how can I get all of the subdirectories dim Drive dim Drives = Directory.GetLogicalDrives() Dim Folder, Folders For each Drive in Drives With TreeView1.Nodes.Add(drive) Folders = Directory.GetDirectories(drive) For each folder in folders .nodes.add(folder) next end with next Quote
*Experts* mutant Posted June 18, 2003 *Experts* Posted June 18, 2003 This article should help you: http://www.vbip.com/miscellaneous/directory-info/dir-info-01.asp Quote
OsirisGothra Posted June 23, 2003 Posted June 23, 2003 If you want populate the tree all at once, I recommend a recursive function to do this... heres some psuedocode: functon addentry(rootnode as node, rootpath as string) get an array of each directory and enter it as a child in this node (be sure to grab a reference to the node you created just in case you have to use it when doing a recursive call) on each child node you add to this 'rootnode' you can check if the directory you are adding has any sub- directories.. if it does, have the function call ITSELF passing the child node and the rootpath + the directory name added to the end of it... otherwise just exit out of the function when you are done adding entries end function If you are reading a large drive though, the above article solves that problem... because populating all at once isnt neccisary unless you really need it :) hope that helped ... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.