0
votes

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

1
Kindly let me know which property you needAshutosh Singh-MVP SharePoint

1 Answers

5
votes

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

}