
Private Sub EnumFolders(Path As String, Optional where As Node)
On Error GoTo errhdl
Dim fso As FileSystemObject
Dim fsl As Folder
Dim fsl1 As Folder
Dim fsf1 As File
Dim ndx As Node
Dim ndx1 As Node
Set fso = New FileSystemObject
Set fsl = fso.GetFolder(Path & "\")
For Each fsl1 In fsl.SubFolders
Randomize
If where Is Nothing Then Set ndx = TreeView1.Nodes.Add(, tvwChild, Rnd(100000) & "key ", fsl1.Name) Else Set ndx = TreeView1.Nodes.Add(where.Key, tvwChild, Rnd(100000) & "key", fsl1.Name)
Call EnumFolders(Path & "\" & fsl1.Name, ndx)
Next fsl1
For Each fsf1 In fsl.Files
If fsf1.Name Like Text1.Text Then
If where Is Nothing Then Set ndx1 = TreeView1.Nodes.Add(, tvwChild, , fsf1.Name) Else Set ndx1 = TreeView1.Nodes.Add(where.Key, tvwChild, , fsf1.Name)
end If
Next fsf1
errhdl:
Select Case Err.Number
Case 76: MsgBox "Cannot read the drive " , vbCritical Or vbOKOnly, "Test"
End Select
Exit Sub
End Sub
Сейчас этот форум просматривают: Majestic-12 [Bot] и гости: 3