展开全部
Private Sub Command1_Click()
Dim fso As New Scripting.FileSystemObject
Dim sFolder As Scripting.Folder
Dim sFolder_1 As Scripting.Folder
Dim FileName As String, myName As String
'显示文件夹
Set sFolder = fso.GetFolder("C:\")
For Each sFolder_1 In sFolder.SubFolders
TreeView1.Nodes.Add.Text = sFolder_1.path
Next
'显示文件
FileName = "C:\*.*"
myName = Dir(FileName)
Do While myName <> ""
TreeView1.Nodes.Add.Text = myName
myName = Dir
Loop
End Sub
Dim fso As New Scripting.FileSystemObject
Dim sFolder As Scripting.Folder
Dim sFolder_1 As Scripting.Folder
Dim FileName As String, myName As String
'显示文件夹
Set sFolder = fso.GetFolder("C:\")
For Each sFolder_1 In sFolder.SubFolders
TreeView1.Nodes.Add.Text = sFolder_1.path
Next
'显示文件
FileName = "C:\*.*"
myName = Dir(FileName)
Do While myName <> ""
TreeView1.Nodes.Add.Text = myName
myName = Dir
Loop
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询