3个回答
展开全部
先引用“Microsoft Scripting Runtime”
Option Explicit
Private fso, objFolder, Folder, txt, DeskTop, Drive, wsh
Private Sub Command1_Click()
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set wsh = CreateObject("Wscript.Shell")
DeskTop = wsh.SpecialFolders("desktop")
Set txt = fso.CreateTextFile(DeskTop & "\AllFolders.txt")
For Each Drive In fso.Drives
Bianli (Drive.RootFolder)
Next
MsgBox "文件夹遍历完毕!"
txt.Close
Set txt = Nothing
Set fso = Nothing
End Sub
Private Sub Bianli(Path As String)
Set Folder = fso.GetFolder(Path)
For Each objFolder In Folder.SubFolders
txt.WriteLine objFolder.Path
Next
For Each objFolder In Folder.SubFolders
Bianli (objFolder.Path & "\")
Next
End Sub
路径保存在桌面上的 AllFolder.txt
Option Explicit
Private fso, objFolder, Folder, txt, DeskTop, Drive, wsh
Private Sub Command1_Click()
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set wsh = CreateObject("Wscript.Shell")
DeskTop = wsh.SpecialFolders("desktop")
Set txt = fso.CreateTextFile(DeskTop & "\AllFolders.txt")
For Each Drive In fso.Drives
Bianli (Drive.RootFolder)
Next
MsgBox "文件夹遍历完毕!"
txt.Close
Set txt = Nothing
Set fso = Nothing
End Sub
Private Sub Bianli(Path As String)
Set Folder = fso.GetFolder(Path)
For Each objFolder In Folder.SubFolders
txt.WriteLine objFolder.Path
Next
For Each objFolder In Folder.SubFolders
Bianli (objFolder.Path & "\")
Next
End Sub
路径保存在桌面上的 AllFolder.txt
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
app.path 当前路径
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询