Retrieve Only the Hidden Lists from SharePoint web using CSOM

  1. //using Microsoft.SharePoint.Client;  
  2. //GetHiddenLists(credentials, weburl);  
  3.   
  4. //This method returns the hidden lists from the web             
  5. private static void GetHiddenLists(ICredentials credentials, string weburl)  
  6. {  
  7.     using (ClientContext ctx = new ClientContext(weburl))  
  8.     {  
  9.         ctx.Credentials = credentials;  
  10.         Web oweb = ctx.Web;  
  11.         ListCollection lists = oweb.Lists;  
  12.   
  13.         var hiddenlistsQuery = from lst in lists  
  14.                                         where lst.Hidden == true  
  15.                                         select lst;  
  16.         IEnumerable<List> hiddenLists = ctx.LoadQuery(hiddenlistsQuery);  
  17.         ctx.ExecuteQuery();                  
  18.         foreach (List lst in hiddenLists)  
  19.         {                      
  20.                 Console.WriteLine(lst.Title);  
  21.         }                  
  22.     }  
  23.     Console.WriteLine("Press any key to exit...");  
  24.     Console.Read();  
  25. }