|
我是新手,下面是自己试写的一段代码,功能是遍历c:\test下所有名为wow.txt的脚本,包括子目录。找到后,以msgbox方式弹出。但执行时,报类型不匹配,请大家帮忙看看原因。
Function pathFind(searchingFolder,searchingFileName,fileType)
tempArray = Split (searchingFileName,".")
fileName = tempArray(0)&"."&fileType
MsgBox (tempArray(0))
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFolder = fso.GetFolder(searchingFolder)
Set objFileCollection = objFolder.Files
For Each objFile In objFileCollection
If objFile.Name = fileName Then
i=i+1
searchedFilePath(i) = objFile.Path
End If
Next
For m=1 To i
MsgBox (searchedFilePath(i)&Chr(10))
Next
Set objSubFoldersCollection = objFolder.SubFolders
For Each objInputSubFolder In objSubFoldersCollection
searchFilePath1 = pathFind(objInputSubFolder,seachingFileName,fileType)
Next
For n=1 To i
pathFind(n) = searchedFilePath(n)
Next
End Function
Call pathFind("C:\test","wow.txt","txt") |
|