ragazzi mi date una mano ad aggiungere le subdirectory compresi i file delle subdirectory.
così mi carcica solo le directory della root invece le subdirectory me li visualizza come file
codice:Imports System.IO Partial Class _Directory Inherits System.Web.UI.Page Private Sub SetChildFolders(ByVal nodes As TreeNodeCollection, ByVal path As String) For Each cartelle As String In IO.Directory.GetDirectories(path) Dim dirInfo As New DirectoryInfo(cartelle) Dim node As New TreeNode(dirInfo.Name, dirInfo.FullName) ' SetChildFolders(node.ChildNodes, dirInfo.FullName) SetChildFiles(node.ChildNodes, dirInfo.FullName) TreeView1.Nodes.Add(node) Next End Sub Private Sub SetChildFiles(ByVal nodes As TreeNodeCollection, ByVal path As String) For Each file As String In Directory.GetFiles(path) Dim fileInfo As New FileInfo(file) nodes.Add(New TreeNode(fileInfo.Name, fileInfo.FullName)) Next End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load TreeView1.Nodes.Clear() SetChildFolders(TreeView1.Nodes, Me.Server.MapPath("~/")) End Sub End Class

Rispondi quotando