如何获取SharePoint中的所有网站和子网站并访问图像库/列表?

发布于 2024-10-06 04:39:13 字数 215 浏览 0 评论 0原文

如何获取SharePoint中的所有网站和子网站并访问图像库/列表?

我期待通过 SharePoint 对象模型实现这一目标。在每个站点或子站点内,我想访问图像库/列表,

alt text

访问此列表后,我该如何将“所选项目所需的内容批准”选项从“是”设置为“否”?

How to get all sites and sub-sites in SharePoint and access an image library/list?

I am looking forward to achieve this via the SharePoint object model. Inside each site or subsite I want to access an image library/list,

alt text

After getting to this list, how do I set the option of 'Required Content Approval for Selected Items' from 'Yes' to 'No'?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如若梦似彩虹 2024-10-13 04:39:13

使用SPFarm对象获取所有Web应用程序,然后使用SPWebApplication获取所有站点集合,然后使用SPSite获取所有Web。

您必须循环遍历所有三个网站才能获取网站集下的所有网站。如果您想查找 spweb 下的子站点,请递归调用所有 spweb,直到在每个 spweb 的 spweb 下找不到任何网站为止。

SPFarm farm = SPFarm.Local;
SPWebService service = farm.Services.GetValue<SPWebService>("");
foreach (SPWebApplication webapp in service.WebApplications)
{
    foreach (SPSite sitecoll in webapp.Sites)
    {
        foreach (SPWeb web in sitecoll.AllWebs)
        {
            <<Use recursion here to Get sub WebS>>
            web.Dispose();
        }
        sitecoll.Dispose();
    }
}

Use the SPFarm object to get all web applications then use SPWebApplication to get all sitecollection and then use SPSite to get all Webs.

You have to loop through all three to get all sites under the site collection. If you want to find subsites under spweb please call all spwebs recursively until you don't find any webs under spweb for each spweb.

SPFarm farm = SPFarm.Local;
SPWebService service = farm.Services.GetValue<SPWebService>("");
foreach (SPWebApplication webapp in service.WebApplications)
{
    foreach (SPSite sitecoll in webapp.Sites)
    {
        foreach (SPWeb web in sitecoll.AllWebs)
        {
            <<Use recursion here to Get sub WebS>>
            web.Dispose();
        }
        sitecoll.Dispose();
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文