How to get the count of documents followed by the user

Steps
  1. Open Visual Studio in your system.
  2. Select Console Applciation template and give as name "GetallList".
  3. Add a Microsoft.Cleint Assembly refrence file in right side refrence tab in visual studio.
  4. Replace Program.cs with the source code below.
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5. using System.Threading.Tasks;  
  6. using Microsoft.SharePoint.Client;  
  7.   
  8. namespace GetallList  
  9. {  
  10.    class Program  
  11.    {  
  12.       static void Main(string[] args)  
  13.       {  
  14.          // ClientContext - Get the context for the SharePoint Site  
  15.   
  16.   
  17.          ClientContext clientContext = new ClientContext("http://gauti.sharepoint.com/sites/SP");  
  18.   
  19.          /Pass the credentials for whom we need to get the count of followed  
  20.          documents  
  21.          //By default It will take current user who runs this application - Here it  
  22.          will take Administrator because the application is running with that account  
  23.   
  24.          clientContext.Credentials = new NetworkCredential("Gowtham""paswword5","SP2013");  
  25.   
  26.          // Get the SocialFollowingManager instance  
  27.          // Provides methods for managing a user's list of followed actors (users,documents, sites, and tags)  
  28.   
  29.          SocialFollowingManager followingManager = new SocialFollowingManager(clientContext);  
  30.   
  31.          // Get the count of followed documents  
  32.   
  33.          ClientResult<int> followingCount =followingManager.GetFollowedCount(SocialActorTypes.Documents);  
  34.   
  35.          // Execute the query to the server  
  36.   
  37.          clientContext.ExecuteQuery();  
  38.   
  39.          // Display the count of followed documents  
  40.   
  41.          Console.WriteLine("Count of followed documents: " + followingCount.Value);  
  42.          Console.ReadLine();  
  43.       }
  44.    }
    }
Output

Hit F5 and Check the Output.
hope you have enjoyed this.!!:-)
Ebook Download
View all
Learn
View all