Steps
- Open Visual Studio in your system.
- Select Console Application template and give the name as "Enablefolder".
- Add a Microsoft.Cleint Assembly reference file in right side reference tab in Visual Studio.
- Replace Program.cs with the source code given below.
In this snippet, ListItemCollectionPosition class is given to implement paging list item retrieval, according to the position of items, which are relative to their collection. We can use the Row limit to return the number of the items per page.
Code snippet
- using System;
- using Microsoft.SharePoint.Client;
-
-
- namespace GowthamArticles
- {
- class itemPositiontItem
- {
- static void Main()
- {
-
- ClientContext clientContext = new ClientContext("https://gowtham.sharepoint.com/tutorials");
- List oList = clientContext.Web.Lists.GetByTitle("Announcements");
-
- ListItemCollectionPosition itemPosition = null;
-
- while (true)
- {
- CamlQuery Query = new CamlQuery();
- camlQuery.ListItemCollectionPosition = itemPosition;
- camlQuery.ViewXml = "<View><ViewFields><FieldRef Name='ID'/>" +
- "<FieldRef Name='Title'/><FieldRef Name='Body'/>" +
- "</ViewFields><RowLimit>10</RowLimit></View>";
-
- ListItemCollection ocollListItem = oList.GetItems(Query);
- clientContext.Load(0collListItem);
- clientContext.ExecuteQuery();
- }
- }
- }