Look up the System.IO namespace. You will need to use recursion to scan folders within folders. Try something like this:
----------------------------------------------------
Sub ScanPath(ByVal PathToScan As String, ByRef CurNode As TreeNode)
Dim CurFolder As String
Dim TotFolders() As String
TotFolders = System.IO.Directory.GetDirectories(PathToScan)
For Each CurFolder In TotFolders
Dim TNode As TreeNode
TNode = New TreeNode(CurFolder)
CurNode.Nodes.Add(TNode)
PathToScan = CurFolder
ScanPath(PathToScan, TNode)
Next
End Sub
---------------------------
Then, this example uses a button to fill the treeview:
----------------------------
Private Sub btnGetFolders_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetFolders.Click
Dim TNode As New TreeNode
TNode = TreeView1.Nodes.Add("C:\windows")
Cursor.Current = Cursors.WaitCursor
ScanPath("C:\windows", TNode)
End Sub
----------------------------
This will get you the folders. See if you can come up with the code to get the files. :)
J
|