0

I have a code that is running through all the Sites that we have created in SharePoint and finding the Sites that have documentation. When I create the SPSite object (?), I am defining a specific directory, but no matter what I seem to do, the script always runs through all the Sites in SharePoint, not just the sites in the specified directory.

Here's what the line of code looks like: using (SPSite site = new SPSite("http://www.mysite.com/myprojects/ABC/"))

I'm trying to get the sites in the ../myprojects/ABC/ directory, but I am getting all the sites within mysite.com

Any ideas or insights would be greatly appreciated.

2
  • The more interesting part of the code would be the start of the iteration code.
    – Paul-Jan
    Jul 17, 2009 at 7:16
  • What do you mean with "Sites that have documentation". What are you exactly looking for?
    – Flo
    Jul 20, 2009 at 8:30

2 Answers 2

1

The question is: what does your iteration code look like? If you do a site.OpenWeb(), then iterate recursively through the direct children using the SPWeb.Webs property, you should be fine.

Your behaviour sounds more like you are using site.AllWebs, which returns all sites (SPWeb) in the site collection.

1
  • 1
    To add to Paul-Jan's point; new SPSite("mysite.com/myprojects/ABC/") Creates a reference to the site collection that hosts that URL. If that's the root web in a site collection .OpenWeb().Webs will give you what you want. If the site collection is actually mysite.com then you'll need to pull a reference to the SPWeb at /myprojects/ABC/ and then use .Webs
    – Mark
    Jul 20, 2009 at 13:02
0

Have you looked at - http://msdn.microsoft.com/en-us/library/ms462161.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.