title: C# and SharePoint 2013 - understanding context and lists
body: <p>I need to get a list of users and the folders they have access to on a SharePoint am already copying files to but can't get my head around the structure of the site so I can get the correct List name in the site.</p>
  
  <p>My URL is <code>https://mySPsite/sites/MySite</code></p>
  
  <p>This is the url that I use to set the context in another function that copies files to the site. The copy locations are in a slightly different format as I use SaveBinaryDirect with the file url in the format <code>/sites/MySite/Shared Documents/MyFolder/MySubFolder</code>. The file copy routines work fine.</p>
  
  <p>What I'm trying to do now is get a list of the folders and the users that have access to them. The folders are all of the <code>MySubFolder</code> folders in <code>MyFolder</code></p>
  
  <p>The problem that I have is that whatever combination of folder names I try I get an error saying the the list cannot be found in the site. I'm using the solution posted below</p>
  
  <pre><code>using (var ctx = new ClientContext(webUri))
  {
  
       var list = ctx.Web.Lists.GetByTitle(listTitle);
       var items = list.GetItems(CamlQuery.CreateAllFoldersQuery());
       ctx.Load(items, icol =&gt; icol.Include(i =&gt; i.RoleAssignments.Include( ra =&gt; ra.Member), i =&gt; i.DisplayName ));
       ctx.ExecuteQuery();
       foreach (var item in items)
       {
          Console.WriteLine("{0} folder permissions",item.DisplayName);
          foreach (var assignment in item.RoleAssignments)
          {
              Console.WriteLine(assignment.Member.Title);
          }
       }
  }
  </code></pre>
  
  <p>by Vadim to get the folder permissions. I'm clearly missing the linkage between <code>WebUri</code> and <code>listTitle</code> and would appreciate any help. </p>