DirSrch Object:

The DirSrch object recursively searches all directories for a specified folder name or partial directory path. Use DirSrch to locate essential folders whose paths are not known.

Properties:
object.StartDirectory = starting directory
StartDirectory specifies where to begin looking for matching directories. All directories under the start directory will be recursively searched.

object.LookingFor = folder name or partial path
LookingFor is the path fragment or directory name to search for. Anything set in LookingFor will be matched to any part of a directory path.
Methods:
object.Execute()
Execute performs the search. The time to complete a search is dependent on the start directory and the size of the drive being searched. Execute must be called before calling any other methods.

object.CountMatches()
Returns a long specifying the number of matching directories found.

object.MatchingDirs()
Returns a collection (array) of matching absolute directory paths.
Syntax:
Set object = New DirSrch
Example Usage:
<%
Dim a, item

 ' create an instance of the DirSrch class
Set a = New DirSrch

 ' set the start directory
a.StartDirectory = "C:\"

 ' find anything matching this fragment path
a.LookingFor     = "java\trustlib"

 ' perform search
a.Execute()

 ' return the number of matches
response.write a.CountMatches() & "<BR>"

 ' return a collection of directories 
 ' matching the search criteria
for each item in a.MatchingDirs()
	response.write item & "<BR>"  ' matching directory
next

 ' release class
Set a = Nothing
%>
ASP Source Code:
<%
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
%>