G
Guest
Hi peeps..
Im using the TreeView control from IE COntrols to create a directory
structure, and trying to do it recursively.
The code works, but my question is simply how can I make the subdirs appear
as leaves in the Tree, rather than as new branches?
Here's the code..
private void RecurseTree(DirectoryInfo theDir, int nLevel)
{
TreeNode libraryNode = null;
DirectoryInfo[] subFolders = theDir.GetDirectories();
// populate the tree
for (int i=0; i < subFolders.Length; i++)
{
libraryNode = new TreeNode();
libraryNode.Text = subFolders.Name;
treeDocuments.Nodes.Add(libraryNode);
libraryNode = null;
RecurseTree(subFolders, nLevel+1);
}
}
Any help appreciated!
Cheers
Dan
Im using the TreeView control from IE COntrols to create a directory
structure, and trying to do it recursively.
The code works, but my question is simply how can I make the subdirs appear
as leaves in the Tree, rather than as new branches?
Here's the code..
private void RecurseTree(DirectoryInfo theDir, int nLevel)
{
TreeNode libraryNode = null;
DirectoryInfo[] subFolders = theDir.GetDirectories();
// populate the tree
for (int i=0; i < subFolders.Length; i++)
{
libraryNode = new TreeNode();
libraryNode.Text = subFolders.Name;
treeDocuments.Nodes.Add(libraryNode);
libraryNode = null;
RecurseTree(subFolders, nLevel+1);
}
}
Any help appreciated!
Cheers
Dan