Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've been able to create doc sets and upload files to it with the client object model. I am having difficulty updating the properties of the files in the doc sets. Here is what I've tried:

    public void UploadDocument(string siteurl, string listname, string docsetname, Microsoft.SharePoint.Client.File filename, string destination)

            using (ClientContext clientContext = new ClientContext(siteurl))
                clientContext.Credentials = new NetworkCredential("username", "password", "domain"); 
                //Get Document List
                List documentsList = clientContext.Web.Lists.GetByTitle(HttpUtility.UrlDecode(listname));


                var xfile = destination + filename.Name;

                //filename.CopyTo(xfile, true);

                //Microsoft.SharePoint.Client.FileInformation fileInformation = Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext, filename.ServerRelativeUrl);
                //Microsoft.SharePoint.Client.File.SaveBinaryDirect(clientContext, destination, fileInformation.Stream, true);

                Microsoft.SharePoint.Client.File.SaveBinaryDirect(clientContext, xfile, 
                    Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext, filename.ServerRelativeUrl).Stream, true);

//==============>this is my problem area <====================

                List oList = clientContext.Web.Lists.GetByTitle("Personnel Files2");

                CamlQuery cq = CamlQuery.CreateAllItemsQuery();
                ListItemCollection personFilesL =  oList.GetItems(cq);


                var liItem = personFilesL.ToList().Select(c => c.FieldValues["Name"] == filename.Name); //.Where(c => c.FieldValues["Name"] == filename.Name).Select(c => c.FieldValues["id"]);
                ListItem li = oList.GetItems(liItem); //.GetItemById(liItem);

                li["Document_x0020_Type"] = "Personnel file";
                li["Country0"] = "1;#China";

//=================> end problem area <=======================


What is the best way to update the properties of the files?

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.