SPSite 目录选择 (C#)
我有一个代码正在运行我们在 SharePoint 中创建的所有网站并查找具有文档的网站。 当我创建 SPSite 对象 (?) 时,我定义了一个特定目录,但无论我做什么,脚本始终会运行 SharePoint 中的所有网站,而不仅仅是指定目录中的网站。
这行代码如下所示: 使用 (SPSite site = new SPSite("http://www.mysite.com/myprojects/ABC/ "))
我正在尝试获取 ../myprojects/ABC/ 目录中的网站,但我正在获取 mysite.com 中的所有网站
任何想法或见解将不胜感激。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是:你的迭代代码是什么样的? 如果您执行 site.OpenWeb(),然后使用 SPWeb.Webs 属性递归地遍历直接子级,那么应该没问题。
您的行为听起来更像是在使用 site.AllWebs,它返回网站集中的所有 网站 (SPWeb)。
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.
您是否看过 - http://msdn.microsoft.com/en-us /library/ms462161.aspx
Have you looked at - http://msdn.microsoft.com/en-us/library/ms462161.aspx