code master
code master

Reputation: 2026

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

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 Libraryalt text

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

Upvotes: 0

Views: 1613

Answers (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();
        }

}

Upvotes: 5

Related Questions