3

I'm new to SharePoint CSOM and I'm trying to get a list of SP Lists/Libraries.

Here's my code:

public LinkedList<string> getLibraries() {
        Web site = spClientContext.Web;
        spClientContext.Load(site.Lists);
        spClientContext.ExecuteQuery();

        LinkedList<string> libraries = new LinkedList<string>();
        foreach (List list in site.Lists)
            libraries.AddLast(list.Title);

        return libraries;
    }

When code is executed CSOM returns all libraries, even those that are hidden from the web interface.
Something like this:

CSOM returned libraries SharePoint 2010 libraries

How can I determine which List/Library to display in my list so that it matches SharePoint UI visible lists?

Brlja
  • 173
  • 1
  • 6
  • Found an similar Stack Overflow article here: http://stackoverflow.com/questions/15293861/filtering-out-hidden-and-system-sharepoint-folders-on-windows-phone-7 – Brlja Feb 22 '16 at 14:49

1 Answers1

2

Just check list.Hidden property, then add in libraries

foreach(List list in site.Lists) {
    if (!list.Hidden) {
        libraries.AddLast(list.Title);
    }
}
Atish Kumar Dipongkor
  • 13,371
  • 5
  • 32
  • 64