Option Explicit Dim FSO As New FileSystemObject Dim currentFolder As Folder Dim currentFolderName As String Dim folderItem,fileItem Private Sub Form_Load() currentFolderName = FSO.GetFolder(App.Path) & "/content" SeachFolder (FSO.GetFolder(currentFolderName)) End Sub Function SeachFolder(str As String) Dim itemFolder Dim curFolder As Folder Set curFolder = FSO.GetFolder(str) Dim itemFile For Each itemFolder In curFolder.SubFolders SeachFolder (CStr(itemFolder)) Me.Text1.Text = Me.Text1.Text & itemFolder & Chr(13) & Chr(10) For Each itemFile In itemFolder.Files Me.Text1.Text = Me.Text1.Text & itemFile & Chr(13) & Chr(10) Next Next End Function
注: 要用FSO,需要引用Microsoft Scripting Runtime,窗体上要放一个text控件,用来显示。