我的代码如下:Private Sub Command1_Click()
Dim str1 As String, path As Stringpath = "c:\tc\"str1 = aaa(path)Text1.Text = str1
End Sub
Function aaa(path)Dim str As String, MyName As Stringstr = ""MyName = Dir(path, vbDirectory) 'will list files and folders
Do While MyName <> ""
If MyName <> "." And MyName <> ".." And ((GetAttr(path & MyName) And vbDirectory) = vbDirectory) Then
str = str & aaa(path & MyName & "\")
Else
str = str & MyName & vbCrLf
End If
MyName = Dir '到时候这一行就会出问题:invalid procedure or argument
Loopaaa = strEnd Function
Dim str1 As String, path As Stringpath = "c:\tc\"str1 = aaa(path)Text1.Text = str1
End Sub
Function aaa(path)Dim str As String, MyName As Stringstr = ""MyName = Dir(path, vbDirectory) 'will list files and folders
Do While MyName <> ""
If MyName <> "." And MyName <> ".." And ((GetAttr(path & MyName) And vbDirectory) = vbDirectory) Then
str = str & aaa(path & MyName & "\")
Else
str = str & MyName & vbCrLf
End If
MyName = Dir '到时候这一行就会出问题:invalid procedure or argument
Loopaaa = strEnd Function
MyName = Dir
以使过程次第进行。但是当你从下级目录返回时,路径已经改变。