Public
Sub
FileTreeSearch(
ByVal
sPath
As
String
,
ByVal
sFileSpec
As
String
, _
ByRef
fileInfo
As
serchFileInfor)
Dim
sDir
As
String
Dim
sSubDirs()
As
String
Dim
iIndex
As
Long
If
Strings.Right(sPath, 1) <> '\'
Then
sPath = sPath & '\'
End
If
sDir = Dir(sPath & sFileSpec)
Do
While
Len(sDir)
fileInfo.fileCount = fileInfo.fileCount + 1
ReDim
Preserve
fileInfo.fileNames(1
To
fileInfo.fileCount)
ReDim
Preserve
fileInfo.fileDirs(1
To
fileInfo.fileCount)
ReDim
Preserve
fileInfo.fileFullNames(1
To
fileInfo.fileCount)
fileInfo.fileNames(fileInfo.fileCount) = sDir
fileInfo.fileDirs(fileInfo.fileCount) = sPath
fileInfo.fileFullNames(fileInfo.fileCount) = sPath & sDir
sDir = Dir
Loop
iIndex = 0
sDir = Dir(sPath &
'*.*'
, vbDirectory)
Do
While
Len(sDir)
If
Strings.Left(sDir, 1) <>
'.'
Then
'skip.and..
If
GetAttr(sPath & sDir)
And
vbDirectory
Then
iIndex = iIndex + 1
ReDim
Preserve
sSubDirs(1
To
iIndex)
sSubDirs(iIndex) = sPath & sDir & '\'
End
If
End
If
sDir = Dir
Loop
For
iIndex = 1
To
iIndex
FileTreeSearch(sSubDirs(iIndex), sFileSpec, fileInfo)
Next
iIndex
End
Function