遍历文件及文件夹

Option Explicit MsgBox "F盘的文件及文件夹" ThroughFiles THroughFolder Sub ThroughFiles Dim fso,AllFiles,EachFile Set fso=CreateObject("Scripting.FileSystemObject") Set AllFiles=fso.GetFolder("F:/") For Each EachFile In AllFiles.Files MsgBox "File : " & """" & EachFile.Name & """" Next End Sub Sub THroughFolder Dim fso,AllFolders,EachFolder Set fso=CreateObject("Scripting.FileSystemObject") Set AllFolders=fso.GetFolder("F:/") For Each EachFolder In AllFolders.SubFolders MsgBox "Folder : " & """" & EachFolder.Name & """" Next End Sub  

 

 

 

这是我这两个星期学期VBS的研究成果之一,呵呵,其实只是把书上讲的属性、方法简单的用了一下,希望对那些学习VBS的人也会有帮助把

你可能感兴趣的:(File,each)