如何从根网站及其所有子网站循环 [英] How to loop through from a root web and all its subsites

查看:50
本文介绍了如何从根网站及其所有子网站循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个需要解决的问题.我想遍历根网站及其所有子网站,并想设置一些属性

I came across a issue that I need to solve. I want to loop through a root web and all its subsites, and want to set some properties

推荐答案

using (SPSite oSPsite = SpSecurityHelper.GetElevatedSite(GetSiteCollection(properties)))
        {
            SPWebCollection siteWebs = oSPsite.AllWebs;
            foreach (SPWeb web in siteWebs)
            {
                try
                {
                    SPList list = null;
                    try
                    {
                        list = web.Lists["Images"];
                    }
                    catch { }

                    if (list != null)
                    {

                        list.EnableModeration = isEnabled == false ? false: true;
                        list.Update();
                    }
                }
                finally
                {
                    if (web != null)
                        web.Dispose();
                }
            }
        }

这篇关于如何从根网站及其所有子网站循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆