Add a TreeView
control on a form and try this:
Option Explicit
Private Sub Form_Load()
pvAddPath TreeView1, "C:\admin\tester1\project\item1\abc"
pvAddPath TreeView1, "C:\admin\tester1\project\item2\abc"
pvAddPath TreeView1, "C:\admin\tester1\project\item1\def"
pvAddPath TreeView1, "C:\admin\tester1\project3\item2\ghi"
End Sub
Private Sub pvAddPath(oCtl As TreeView, ByVal sPath As String)
Dim lNext As Long
Dim lStart As Long
If oCtl.Nodes.Count = 0 Then
oCtl.Indentation = 0
End If
Do While lStart < Len(sPath)
lNext = InStr(lStart + 1, sPath, "\")
If lNext = 0 Then
lNext = Len(sPath) + 1
End If
On Error Resume Next
If lStart = 0 Then
oCtl.Nodes.Add(, , Left$(sPath, lNext), Left$(sPath, lNext)).Expanded = True
Else
oCtl.Nodes.Add(Left$(sPath, lStart), tvwChild, Left$(sPath, lNext), Mid$(sPath, lStart + 1, lNext - lStart - 1)).Expanded = True
End If
On Error GoTo 0
lStart = lNext
Loop
End Sub