|
- Function pathFind( searchingFolder,searchingFileName,fileType)
- '根据传入的根目录,查找该目录下的指定名称,以及指定文件类型的文件,并返回其绝对路径。
- tempArray = Split(searchingFileName,".")
- fileName = tempArray(0)&"."&fileType
- 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 = objFile.Path
- Exit for
- End If
- Next
- If i=0 then
- '遍历子文件夹
- Set objSubFoldersCollection = objFolder.SubFolders
- For each objInputSubFolder in objSubFoldersCollection
- searchedFilePath= pathFind(objInputSubFolder,searchingFileName,fileType)
- If searchedFilePath<>"" Then
- Exit For
- End if
- Next
- End If
- pathFind = searchedFilePath
- End Function
复制代码 |
|