请高手帮我看看,我做的 资源管理器那里有毛病?
请高手帮我看看,我做的资源管理器那里有毛病?为什么只能显示到磁盘 而不能显示下级文件夹,?Imports Public Class frmexplorer
Inherits System.Windows.Forms.Form
Dim strcurrentpath As String
Dim strcurrentfile As String
Dim tvcurrentnode As TreeNode
Dim copysourcefile As String, copyfilename As String
Dim contextmenufocus As Integer
Dim bmodify As Boolean = False
Dim seditfilename As String
#Region "windows窗体设计生成器的代码"
#End Region
#Region "浏览磁盘、文件夹及文件的操作,熟悉常用空件"
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
If e.Node.Text = "我的电脑" Then
dispdriver(e.Node)
Else : dispdriver(e.Node)
End If
End Sub
Private Sub dispdriver(ByVal node As TreeNode)
Dim drv As String
Dim i As Integer
If node.Nodes.Count = 0 Then
For Each drv In Directory.GetLogicalDrives
Dim tmpnode As New TreeNode
TreeView1.SelectedNode = node
Dim temnode As New TreeNode
tmpnode.Text = drv.Substring(0, drv.Length)
tmpnode.Text = drv
tmpnode.Tag = drv
tmpnode.ImageIndex = 1
tmpnode.SelectedImageIndex = 1
TreeView1.SelectedNode.Nodes.Add(tmpnode)
TreeView1.SelectedNode.Nodes(i).EnsureVisible()
i = i + i
Next
End If
End Sub
Private Sub dispdir(ByVal node As TreeNode)
Try
TreeView1.SelectedNode = node
Dim directorypath As String = node.Tag.ToString()
If directorypath.Substring(directorypath.Length - 1) <> "\" Then
directorypath += "\"
End If
strcurrentpath = directorypath
tvcurrentnode = TreeView1.SelectedNode
Dim dir As String
Dim i As Integer
For Each dir In Directory.GetDirectories(directorypath)
Dim tmpnode As New TreeNode
tmpnode.Text = dir.Substring(dir.LastIndexOf("\") + 1)
tmpnode.Tag() = dir
tmpnode.ImageIndex = 2
tmpnode.SelectedImageIndex = 3
TreeView1.SelectedNode.Nodes.Add(tmpnode)
TreeView1.SelectedNode.Nodes(i).EnsureVisible()
i += 1
Next
ListView1.Update()
dispfile(node)
Catch ex As Exception
End Try
End Sub
Private Sub dispfile(ByVal node As TreeNode)
Dim directorypath As String = node.tag.tostring()
If directorypath.Substring(directorypath - 1) <> "\" Then
directorypath += "\"
End If
Try
ListView1.Items.Clear()
Dim tmpfile As String
Dim lvitem As ListViewItem
For Each tmpfile In Directory.GetFiles(directorypath)
lvitem = New ListViewItem(Path.GetFileName(tmpfile))
lvitem.SubItems.Add(File.GetLastAccessTime(tmpfile))
ListView1.Items.Add(lvitem)
Next
ListView1.Update()
Catch ex As Exception
End Try
End Sub
#End Region