0

I am very new to shareopoint development. In my project I want to read the contents of the ListItems according to its versions. Here is my pseudo code

                      foreach (ListItem oListItem in listItemCollection)
                            {
                                var item=  wb.GetItemById(oListItem.Id);

                                clientcontext.Load(item, 
                                it => it.Id, it => it.DisplayName,   
                                it=>it.ContentType,it=>it.File);

                                clientcontext.ExecuteQuery();

                                Console.WriteLine(itm.DisplayName);                                    

                                var strm = item.File.ListItemAllFields;

                                clientcontext.Load(strm);
                                clientcontext.ExecuteQuery(); 
                            }

How can I read the contents of ListItem according to its version?

Thanks in Advance.

2

You can try below code.

foreach (Microsoft.SharePoint.Client.FileVersion itemVersion in pageItem.File.Versions)
{
      pageVersion = itemVersion.VersionLabel + ";" + pageVersion;
      Console.WriteLine(itemVersion.VersionLabel);
}

Hope this helps to give you some idea to start with.


To get the older version content

You have to checkout the file. Make previous version as current version. Get the content of the file Undo checkout.

|improve this answer|||||
  • Thanks this gives me the version of the item. But how can I get contents of the item – Mayuresh Dec 6 '17 at 12:29
  • Edited my answer.!! – users1100 Dec 7 '17 at 5:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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