How to enable Version to document library Programmatically
public void CheckVersionEnable(string ListName)
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite osite = new SPSite("http://URL/"))
{
using (SPWeb oweb = osite.OpenWeb("http://URL/"))
{
SPList docs = oweb.Lists[ListName];
if (docs.EnableVersioning == false)
{
docs.EnableVersioning = true;
docs.MajorVersionLimit = 10;
oweb.AllowUnsafeUpdates = true;
docs.Update();
oweb.AllowUnsafeUpdates = false;
}
}
}
});
}
Comments
Post a Comment