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

Popular posts from this blog

IRM and the Object Model

This content database has a schema version which is not supported in this farm

Activate and Deactivate Feature through PowerShell