<%
Class DirSrch
Private strTmp1, strTmp2, gblMatches, bExecuted
Private Sub Class_Initialize()
bExecuted = False
End Sub
Private Function FindDir(byVal directory, byVal DirToFind)
if len( directory ) = 0 and len( dirtofind ) = 0 then
FindDir = "" & vbCrLf
Exit Function
end if
dim objFSO, fldr, folder, tmp
set objFSO = Server.CreateObject(_
"Scripting.FileSystemObject")
set fldr = objfso.getfolder(directory)
for each folder in fldr.subfolders
if UCase( folder.name ) = _
UCase( DirToFind ) Then
tmp = tmp & folder.path & vbCrLf
elseif InStr( UCase( folder.path ), _
UCase( DirToFind ) ) Then
tmp = tmp & folder.path & vbCrLf
else
' tmp = join(tmp, vbCrLf)
tmp = tmp & FindDir( _
folder.path, DirToFind )
end if
next
set fldr = nothing
set objfso = nothing
FindDir = tmp
End Function
Public Sub Execute()
dim a, b
a = split( FindDir( StartDirectory, _
LookingFor ), vbCrLf )
b = ubound(a) - 1
ReDim Preserve a(b)
gblMatches = a
bExecuted = True
End Sub
Public Function MatchingDirs()
If Not bExecuted then
Err.Raise 5199, "DirSrch Class", _
"Cannot Call 'MatchingDirs' before " & _
"calling the 'Execute' method."
Exit Function
End If
MatchingDirs = gblMatches
End Function
Public Function CountMatches()
If Not bExecuted then
Err.Raise 5199, "DirSrch Class", _
"Cannot Call 'CountMatches' before " & _
"calling the 'Execute' method."
Exit Function
End If
CountMatches = CLng( ubound( gblMatches ) + 1 )
End Function
Public Property LET StartDirectory(byVal strInput)
strTmp1 = strInput
End Property
Public Property LET LookingFor(byVal strInput)
strTmp2 = strInput
End Property
Public Property GET StartDirectory()
if Len( strTmp1 ) = 0 then
Err.Raise 5199, "DirSrch Class", _
"You must set the 'StartDirectory' property " & _
"before calling the 'Execute' method."
Exit Property
end if
StartDirectory = strTmp1
End Property
Public Property GET LookingFor()
if Len( strTmp2 ) = 0 then
Err.Raise 5199, "DirSrch Class", _
"You must set the 'LookingFor' property " & _
"before calling the 'Execute' method."
Exit Property
end if
LookingFor = strTmp2
End Property
End Class
%>