How to get an image library properties in a site and all its subsites in SharePoint?

旧城冷巷雨未停 提交于 2020-01-06 15:50:13

问题


I have an image library in a site and its subsite and I want to access its properties using the SharePoint object model. I don't know how to achieve that using SharePoint Object Model. Here is the image of that Library

Note here is the structure of my SharePoint sites and subsites. You can see the 'Images' Library in each of sites and subsite.


回答1:


All these properties are available under SPList

  using (SPSite oSPsite = new SPSite("spdev/";)) {
using (SPWeb oSPWeb = oSPsite.OpenWeb())
 { 
    SPList list = oSPWeb.GetList("PublishingImages"); 
    list.EnableModeration = true;
    if (oSPWeb.Webs.Count > 0 ) 
    {
    recursivewebcheck(oSPweb);
    }
 } 

Void recursivewebcheck(SPWeb oSPweb)
{

    foreach (SPWeb web in oSPWeb.Webs)
        { 
            SPList list = web.GetList("PublishingImages"); 
            list.EnableModeration = true; web.Dispose(); 
            if (oSPWeb.Webs.Count > 0 ) 
            {
                recursivewebcheck(web);
            }
            web.dispose();
        }

}


来源:https://stackoverflow.com/questions/4376732/how-to-get-an-image-library-properties-in-a-site-and-all-its-subsites-in-sharepo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!