Private Function OutputDirectory(directory As System.IO.DirectoryInfo, parentNode As TreeNode) As TreeNode
' validate param
If directory Is Nothing Then
Return Nothing
End If
' create a node for this directory
Dim DirNode As New TreeNode(directory.Name)
' get subdirectories of the current directory
Dim SubDirectories As System.IO.DirectoryInfo() = directory.GetDirectories()
' OutputDirectory(SubDirectories[0], "Directories");
' output each subdirectory
For DirectoryCount As Integer = 0 To SubDirectories.Length - 1
OutputDirectory(SubDirectories(DirectoryCount), DirNode)
Next
' output the current directories file
Dim Files As System.IO.FileInfo() = directory.GetFiles()
For FileCount As Integer = 0 To Files.Length - 1
DirNode.ChildNodes.Add(New TreeNode(Files(FileCount).Name))
Next
' if the parent node is null, return this node
' otherwise add this node to the parent and return the parent
If parentNode Is Nothing Then
Return DirNode
Else
parentNode.ChildNodes.Add(DirNode)
Return parentNode
End If
End Function
yaptım hocam bu kodla treeview de listelettim çok sağolasın