0

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
code master
  • 2,026
  • 5
  • 30
  • 49

1 Answers1

5

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

}
  • I want to iterate through the site and subsites structure first! and then I can get the properties. Well, I want to access the content approval property. i want to set it to false. – code master Dec 07 '10 at 13:12
  • Refer to this question i have answered a similar question http://stackoverflow.com/questions/4344187/how-to-get-all-sites-and-sub-sites-in-sharepoint-and-access-an-image-library-list/4344547#4344547 – Ashutosh Singh-MVP SharePoint Dec 07 '10 at 13:14
  • It seems you had asked the same question previously as well do you need full code? – Ashutosh Singh-MVP SharePoint Dec 07 '10 at 13:15
  • using (SPSite oSPsite = new SPSite("http://spdev/")) using (SPWeb oSPWeb = oSPsite.OpenWeb()) { SPList list = oSPWeb.GetList("PublishingImages"); list.EnableModeration = true; foreach (SPWeb web in oSPWeb.Webs) { SPList list = web.GetList("PublishingImages"); list.EnableModeration = true; web.Dispose(); } } – code master Dec 07 '10 at 13:19