Treeview

Z

Zulander

Hi, i am having problem with Treeview, i don't know why but i i am
unable to create sub nodes this is my code:


Dim xMonitor As New FileMonitor.Monitor
Dim Folders() As String
Dim Files() As String
Dim i As Integer
Dim z As Integer

Folders = xMonitor.ListOfFolders("C:\UserFolder\")

Dim MainNode As TreeNode = New TreeNode

MainNode.Text = "C:\UserFolder\"
TreeView1.Nodes.Add(MainNode)

For i = UBound(Folders) To 0 Step -1
Dim FolderNode As TreeNode = New TreeNode
FolderNode.Text = Folders(i).Replace("C:\UserFolder\", "")
Files = xMonitor.ListOfFile(Folders(i))
MainNode.ChildNodes.Add(FolderNode)

For z = UBound(Files) To 0 Step -1
Dim SubFileNode As TreeNode = New TreeNode
SubFileNode.Text = System.IO.Path.GetFileName(Files(z))
FolderNode.ChildNodes.Add(SubFileNode)
Next

Next
Files = xMonitor.ListOfFile("C:\UserFolder\")
For z = UBound(Files) To 0 Step -1
Dim FileNode As TreeNode = New TreeNode
FileNode.Text = Files(z).Replace("C:\UserFolder\", "")
MainNode.ChildNodes.Add(FileNode)
Next


I am getting the fallowing results:

C:\UserFolder\
\Sub1\
208.jpg
\Sub1\Sub 2\
207.jpg
\Sub1\Sub 2\Sub3\
209.jpg
198.jpg
197.jpg
196.jpg

I would like to get the fallowing results:
C:\UserFolder\
\Sub1\
208.jpg
\Sub 2\
207.jpg
Sub3\
209.jpg
198.jpg
197.jpg
196.jpg

output my my file listing is :


198.jpg
197.jpg
196.jpg
Sub1\
Sub1\208.jpg
Sub1\Sub 2\
Sub1\Sub 2\207.jpg
Sub1\Sub 2\Sub3\
Sub1\Sub 2\Sub3\209.jpg

Thnak you, !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,186
Latest member
vinaykumar_nevatia

Latest Threads

Top