0
votes

I'm working with SharePoint 2013 and trying to return all the lists that exist within a Site URL. I've tried the code below, but it returns an initialization error. How can I properly return these lists?

foreach (List li in clientContext.Web.Lists)
        {
            Console.WriteLine(li.Title);
        }
        Console.Read();
1

1 Answers

0
votes

I figured it out on my own. A new ListCollection needs to be created, then the ListCollection pulled down from the SharePoint server can be populated into it after ExecuteQuery is called. See example below.

ListCollection lc = clientContext.Web.Lists;
clientContext.Load(lc);
clientContext.ExecuteQuery();

foreach (List l in lc)
    {
        {
            //Do work here
        }
    }