TFS SharePoint检索项目列表

时间:2009-09-28 05:12:17

标签: tfs

背景 在TFS中,无论何时创建新项目,都会在http://sharepoint/sites/projectname下创建新的SharePoint站点。要查看这些子网站,以下是描述它的链接:

http://blog.aggregatedintelligence.com/2009/04/viewing-list-of-tfs-portals-in.html

现在,我想创建一个SharePoint webpart,用于检索http://sharepoint/sites下的所有项目。我使用以下方法:

        using (SPSite site = new SPSite("http://sharepoint/sites/"))
        {

            foreach (SPWeb web in site.AllWebs)
            {
                //do operations here
            }
        }

现在问题是它不起作用。该站点不检索这些目录下的站点。我该怎么做?

1 个答案:

答案 0 :(得分:0)

我希望您没有收到任何回复的原因是因为/sites/实际上并不是SharePoint上的网站集,如果您尝试访问/sites/,则会注意到SharePoint服务器上的路径。

您可能只需要从根网站返回所有网站,然后只需过滤路径名称,无论它是否包含/sites/。我相信这是管理中心在Web应用程序列表中显示站点列表的方式。