Reputation: 2026
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.
Upvotes: 0
Views: 1613
Reputation: 5293
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