Background
in TFS whenever you create a new project, a new SharePoint site is created under http://sharepoint/sites/projectname. To see those subsites, the following is the link that describe it:
http://blog.aggregatedintelligence.com/2009/04/viewing-list-of-tfs-portals-in.html
Now I want to create a SharePoint webpart that retrieve all of the projects under http://sharepoint/sites. I use the following method:
using (SPSite site = new SPSite("http://sharepoint/sites/"))
{
foreach (SPWeb web in site.AllWebs)
{
//do operations here
}
}
Now the thing is that it doesn't work. The site does not retrieve the sites under those directories. How do I do that?
Best Answer
I'd expect that the reason you're not getting anything back is because
/sites/
isn't really a site collection on SharePoint, which you'd notice if you try and access/sites/
as a path on the SharePoint server.You'll probably have to just return all the sites from the root web and then just filter on the path name whether or not it contains
/sites/
. I believe that is how Central Administration displays the list of sites within the web application list.