|
Option Base 1
Dim jg(), k&
Sub perpare()
Dim i%, j%, fso As Object, str$, ar(1): str = "F:\"
ReDim jg(2): jg(1) = str
Set fso = CreateObject("scripting.filesystemobject")
Call bianli(fso, str)
End Sub
Sub bianli(fso As Object, str$)
Dim file As Object, nod As Node
For Each file In fso.getfolder(str).subfolders
k = 0
Call add(jg, str, file.Path)
Call bianli(fso, file.Path)
Next
End Sub
Sub add(jg, str$, str1$)
On Error Resume Next
Dim i%, ar, br(2), cr(2): k = k + 1
If k = 1 Then
If jg(1) = str Then
If IsArray(jg(2)) Then
ar = jg(2)
ReDim Preserve ar(UBound(ar) + 1)
br(1) = str1: ar(UBound(ar)) = br
jg(2) = ar
Exit Sub
Else
cr(1) = str1
jg(2) = cr: Exit Sub
End If
End If
Call add(jg(2), str, str1)
Else
If Not IsArray(jg) Then Exit Sub
For i = 1 To UBound(jg)
If IsArray(jg(i)) Then
If jg(i)(1) = str Then
ar = jg(i)(2)
If IsArray(jg(i)(2)) Then
ReDim Preserve ar(UBound(ar) + 1)
br(1) = str1: ar(UBound(ar)) = br
jg(i)(2) = ar: Exit Sub
Else
cr(1) = str1
jg(i)(2) = cr: Exit Sub
End If
End If
End If
Call add(jg(i), str, str1)
Next
End If
End Sub
|
|