Previous in Contents Next in Contents

Creating and Accessing ISitePath Interface Objects

You create an ISitePath interface object by calling the ISitePaths.Add method. You can access a specific ISitePath interface object by calling the Item property. Because ISitePaths is a collection, you can access all ISitePath interface objects using a for each loop, as in the following example, where objPath is the name you give to the ISitePath interface object:

Option Explicit 
On Error Resume Next 

Sub DumpPaths()
  Wscript.Echo "The paths are crawled or avoided in the following order:"

  For Each objPath in objSite.Paths
    If objPath.Included Then
      Wscript.Echo "  " & objPath.Path & " is crawled,"
 
      If objPath.IncludeSubdirs Then 
        Wscript.Echo "    and so are its subdirectories"
      Else
        Wscript.Echo "    but its subdirectories are not crawled."
      End If
    Else
      Wscript.Echo "  " & objPath.Path & " is not crawled."
    End If
  Next

  Wscript.Echo "" 
End Sub

Dim objSearchAdmin, objBuildCatalog, Site, objSite, Path1, Path2, objPath 
Site = "www.microsoft.com"
Path1 = "/SiteServer"
Path2 = "/Msdn"

Set objSearchAdmin   = CreateObject("Search.SearchAdmin.1") 
Set objBuildCatalog  = _
  objSearchAdmin.BuildServer.BuildCatalogs("KMSampleCatalog1")
Set objSite          = objBuildCatalog.Sites.Item(Site)

objSite.Paths.Add Path1, False 
objSite.Paths.Add Path2, True

'Display the paths before changing the order
DumpPaths

Path2 = "http://" & WebSite & Path2

objSite.Paths.ChangeOrder Path2, True 

'Display the paths after changing the order
DumpPaths

'Release objects 
Set objPath         = Nothing 
Set objSite         = Nothing 
Set objBuildCatalog = Nothing 
Set objSearchAdmin  = Nothing 
 

© 1997-2000 Microsoft Corporation. All rights reserved.