|
楼主 |
发表于 2024-4-28 16:16
|
显示全部楼层
拒绝的权限?????
- Sub Test()
- TraverseSubFolder "D:" ' & "Streetsnap"
-
- End Sub
- Sub TraverseSubFolder(FolderPath)
- Dim T: T = Time
- Dim Fso As FileSystemObject
- Set Fso = New FileSystemObject
-
- Dim CurFolder As Folder
- Dim SubFolder As Folder
- Dim oFolder As Folder
-
-
- Set CurFolder = Fso.GetFolder(FolderPath)
-
- ' 遍历当前文件夹的子文件夹
- For Each SubFolder In CurFolder.SubFolders
- ' 处理子文件夹
-
- Debug.Print SubFolder.Path, SubFolder.Type
- If InStr(SubFolder.Path, "System Volume Information") = 0 And InStr(SubFolder.Path, "$RECYCLE") = 0 And InStr(SubFolder.Path, "-") = 0 Then
- 'And InStr(SubFolder.Path, "360Downloads") = 0 _
- ' And InStr(SubFolder.Path, "360Re") = 0 And InStr(SubFolder.Path, "360安全浏览器下载") = 0 And InStr(SubFolder.Path, "360驱动大师目录") = 0 Then
-
- 'Set oFolder = SubFolder
- If SubFolder.SubFolders.Count = 0 And SubFolder.Files.Count = 0 Then
- Debug.Print SubFolder.Path, SubFolder.SubFolders.Count, SubFolder.Files.Count
- Fso.DeleteFolder SubFolder
- GoTo 100
- End If
- End If
-
- ' 递归调用,继续遍历子文件夹的子文件夹
- 'If Fso.FolderExists(SubFolder.Path) = True Then
- TraverseSubFolder SubFolder.Path
- 'End If
- 100:
- Next SubFolder
- End Sub
-
复制代码
|
|