123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home

Source Codes

Engineering Colleges

BE Students

Training  Reports (updated)

Seminar Reports (updated

Placement Papers (updated)

Forums

   Computer Science / IT

   Electronics

   Electrical

   Mechanical

   Chemical

   Civil

   CAT / MBA

   GMAT / Foreign MBA

Latest Jobs

Engineering Jobs / Technical Jobs

Management Jobs

Sitemap

About-Us

Terms of use

Displaying  Source Code(s)  
 

 
DirSrch Object

--------------------------------------------------------------------------------

Description : 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.


<%
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
%>

--------------------------------------------------------------------------------
 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG