What I am trying to do is build a directory path from the children of a selected Node. But it seems the code I have forgets a few nodes and the path is not being built correctly.
Tree Structure
Treenode1(SelectedNode
---------NodeB
--------------NodeB Child
--------------NodeB Child
---------NodeC
---------NodeD
Treenode2
My code
Private Function GetSelectedNode_Children(ByVal SelectedParentNode As TreeNode)
BuildDirNode(SelectedParentNode)
If SelectedParentNode.GetNodeCount(True) > 0 Then
For Each childnodes As TreeNode In SelectedParentNode.Nodes
BuildDirNode(childnodes)
If SelectedParentNode.GetNodeCount(True) > 0 Then
GetSelectedNode_Children(childnodes)
End If
Next
End If
End Function
Private Sub BuildDirNode(ByVal nd As TreeNode)
ExportPath = ExportPath & "\" & nd.Text
If Not System.IO.Directory.Exists(ExportPath) = True Then
System.IO.Directory.CreateDirectory(ExportPath)
'Do file stuff here
End If
End Sub
I have tried using the nodes in a collection but the same end result. Please Help