using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
using (SPSite oSPsite = new SPSite("http://sharepointdev:2021"))
{
using (SPWeb oSPWeb = oSPsite.OpenWeb())
{
foreach (SPList list in oSPWeb.Lists)
{
if ( list.ContentTypes.Count > 0)
{
foreach (SPContentType contentType in list.ContentTypes)
{
if (contentType.Name == "Document")
{
list.EnableModeration = true;
list.Update();
}
}
}
}
if(oSPWeb.Webs.Count > 0)
recursivewebcheck(oSPWeb);
}
}
}
static void recursivewebcheck(SPWeb oSPWeb)
{
foreach (SPWeb web in oSPWeb.Webs)
{
foreach (SPList list in oSPWeb.Lists)
{
if (list.ContentTypes.Count > 0)
{
foreach (SPContentType contentType in list.ContentTypes)
{
if (contentType.Name == "Document")
{
list.EnableModeration = true;
list.Update();
}
}
}
}
if (web.Webs.Count > 0)
{
recursivewebcheck(web);
}
web.Dispose();
}
}
}
}