4

i am trying to enable versioning on a ducument library using the client object model my code currently is as follows when i create the document library.

            ClientContext clientContext = getClientContext();
        try
        {
            Web web = clientContext.Web;
            ListCollection listCol = web.Lists;
            ListCreationInformation lci = new ListCreationInformation();
            lci.Title = DocLib;
            lci.TemplateType = (int)ListTemplateType.DocumentLibrary;
            List documentLibrary = listCol.Add(lci);
            documentLibrary.EnableVersioning = true;
            documentLibrary.EnableMinorVersions = true;
            documentLibrary.ContentTypesEnabled = true;
            clientContext.Load(listCol);
            clientContext.ExecuteQuery();
            Console.WriteLine("doclibCreated created");
            return documentLibrary;
        }
        catch (Microsoft.SharePoint.Client.ServerException e)
        {
            Console.WriteLine(e.Message);
            return null;
        }

but these settings are not persisted

1 Answer 1

4

You need to call Update() to apply document library properties:

.
.
documentLibrary.ContentTypesEnabled = true;

documentLibrary.Update();   <---- ADDED

clientContext.Load(listCol);
.
.
1
  • ah yes that makes sense thatnks alot :) Commented Oct 4, 2011 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.