1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
Public Function FindFileRecursively(ByVal strRootFolder, ByVal strFilename) Dim FSO Dim strFullPathToSearch Dim objSubFolders, subfolder Set FSO = CreateObject("Scripting.FileSystemObject") FindFileRecursively = "" If strFileName = "" Then Exit Function strFullPathToSearch = strRootFolder & "" & strFilename If FSO.FolderExists(strRootFolder) Then If FSO.FileExists(strFullPathToSearch) Then FindFileRecursively = strFullPathToSearch Else Set objSubFolders = FSO.GetFolder(strRootFolder).SubFolders For Each subfolder in objSubFolders strFullPathToSearch = strRootFolder & "" & subfolder.name FindFileRecursively = FindFileRecursively(strFullPathToSearch, strFilename) If FindFileRecursively <> "" Then Exit For End If Next End If End If End Function
|
近期评论