|
感谢楼上的代码,发现LS的只能遍历下面一层的文件名,在此基础上稍加修改,使之能遍历全部,请试验一下,谢谢
' Definition of the function
Function ShowFolderList(folderspec)
Dim fs, f, f1, fc
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 in fc
ShowFolderList = ShowFolderList & f1.name
ShowFolderList = ShowFolderList & vbCrLf
MsgBox f1.name
ShowFolderList(folderspec+"\"+f1.name)
Next
' releae the resoure
Set fs = nothing
Set f = nothing
Set fc = nothing
End Function
' call the function
ShowFolderList("C:\temp")
欢迎批评指正,呵呵 |
|