title: List files all files in folder on Sharepoint online with C#
body: <p>Trying to list all files in a directory in Sharepoint online. But get an exception on line <em>Microsoft.SharePoint.Client.ServerException: 'List 'Shared%20Documents' does not exist at site with URL 'https://MySite.sharepoint.com/sites/TeamSite'.'</em></p>
  <p>The directory exists and finds it and under the directory when retrieving the directory.  Do not know if it is the right way to retrieve a file from Sharepoint online.</p>
  <pre><code>using Microsoft.SharePoint.Client;
  using OfficeDevPnP.Core;
  using System.Collections.Generic;
  using System.IO;
  
  namespace Sharepoint
  {
  class Program
  {
      static void Main(string[] args)
      {
          string siteUrl = &quot;https://MySite.sharepoint.com/sites/TeamSite&quot;;
          List&lt;ListItem&gt; items = new List&lt;ListItem&gt;();
  
          using (var clientContext = new AuthenticationManager().GetAppOnlyAuthenticatedContext(siteUrl, appId, AppSecred))
          {
              Web web = clientContext.Web;
  
              clientContext.Load(web);
              clientContext.Load(web.Lists);
              clientContext.Load(web, wb =&gt; wb.ServerRelativeUrl);
              clientContext.ExecuteQuery();
  
              Folder folder = web.GetFolderByServerRelativeUrl(web.ServerRelativeUrl + &quot;/Shared%20Documents/Testfolder/&quot;);
              clientContext.Load(folder);
              clientContext.ExecuteQuery();
  
              List list = web.Lists.GetByTitle(&quot;Shared%20Documents&quot;);
              clientContext.Load(list);
              clientContext.ExecuteQuery(); //Throws an exception. Microsoft.SharePoint.Client.ServerException: 'List 'Shared%20Documents' does not exist at site with URL 'https://MySite.sharepoint.com/sites/TeamSite'.'
  
              CamlQuery camlQuery = new CamlQuery();
              camlQuery.ViewXml = @&quot;&lt;View Scope='Recursive'&gt;&lt;Query&gt;&lt;/Query&gt;&lt;/View&gt;&quot;;
              camlQuery.FolderServerRelativeUrl = folder.ServerRelativeUrl;
              ListItemCollection listItems = list.GetItems(camlQuery);
             
              // Todo
              clientContext.Load(listItems);
              clientContext.ExecuteQuery();
          };
      }
  }
  </code></pre>
  <p>}</p>