title: Create folder structure in a Sharepoint online list
body: <p>I'm trying to create a folder structure under a list in Sharepoint online.
  I created a list called Shared1 according to this article:</p>
  
  <p><a href="http://blogs.technet.com/b/catastrophic_failure_joannav/archive/2013/10/23/how-to-create-a-custom-list-in-sharepoint-online-quot-w15-quot.aspx" rel="nofollow noreferrer">http://blogs.technet.com/b/catastrophic_failure_joannav/archive/2013/10/23/how-to-create-a-custom-list-in-sharepoint-online-quot-w15-quot.aspx</a></p>
  
  <p>And I'm using this code for trying to create an underlying structure:</p>
  
  <pre><code>using (var clientContext = new ClientContext("https://myEnv.sharepoint.com"))
  {
      var passWord = new SecureString();
      foreach (char c in "myPSW".ToCharArray()) passWord.AppendChar(c);
  
      clientContext.Credentials = new SharePointOnlineCredentials("myAcc@myenv.onmicrosoft.com", passWord);
      Web web = clientContext.Web;
      clientContext.Load(web);
      clientContext.ExecuteQuery();
      var folder = CreateFolder(clientContext.Web, "Shared1", "FolderA/SubFolderA/SubSubFolderA");
  }
  
  /// &lt;summary&gt;
  /// Create Folder client object
  /// &lt;/summary&gt;
  /// &lt;param name="web"&gt;&lt;/param&gt;
  /// &lt;param name="listTitle"&gt;&lt;/param&gt;
  /// &lt;param name="fullFolderUrl"&gt;&lt;/param&gt;
  /// &lt;returns&gt;&lt;/returns&gt;
  public static Folder CreateFolder(Web web, string listTitle, string fullFolderUrl)
  {
      if (string.IsNullOrEmpty(fullFolderUrl))
          throw new ArgumentNullException("fullFolderUrl");
      var list = web.Lists.GetByTitle(listTitle);
      return CreateFolderInternal(web, list.RootFolder, fullFolderUrl);
  }
  
  private static Folder CreateFolderInternal(Web web, Folder parentFolder, string fullFolderUrl)
  {
      var folderUrls = fullFolderUrl.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
      string folderUrl = folderUrls[0];
      var curFolder = parentFolder.Folders.Add(folderUrl);
      web.Context.Load(curFolder);
      web.Context.ExecuteQuery();
  
      if (folderUrls.Length &gt; 1)
      {
          var subFolderUrl = string.Join("/", folderUrls, 1, folderUrls.Length - 1);
          return CreateFolderInternal(web, curFolder, subFolderUrl);
      }
      return curFolder;
  }
  
  public static Folder GetFolder(Web web, string fullFolderUrl)
  {
      if (string.IsNullOrEmpty(fullFolderUrl))
          throw new ArgumentNullException("fullFolderUrl");
  
      if (!web.IsPropertyAvailable("ServerRelativeUrl"))
      {
          web.Context.Load(web, w =&gt; w.ServerRelativeUrl);
          web.Context.ExecuteQuery();
      }
      var folder = web.GetFolderByServerRelativeUrl(web.ServerRelativeUrl + fullFolderUrl);
      web.Context.Load(folder);
      web.Context.ExecuteQuery();
      return folder;
  }
  </code></pre>
  
  <p>And upon the execution I get this error:</p>
  
  <pre><code>Unhandled Exception: Microsoft.SharePoint.Client.ServerException: List 'Shared1'
   does not exist at site with URL 'https://myEnv.sharepoint.com'.
     at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream res
  ponseStream)
     at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
     at SharepointFolderRename.Program.CreateFolderInternal(Web web, Folder parent
  Folder, String fullFolderUrl) in \\vmware-host\shared folders\Documents\Visual S
  tudio 2012\Projects\Trunk2015\SharepointFolderRename\Program.cs:line 84
     at SharepointFolderRename.Program.Main(String[] args) in \\vmware-host\shared
   folders\Documents\Visual Studio 2012\Projects\Trunk2015\SharepointFolderRename\
  Program.cs:line 49
  </code></pre>
  
  <p>This is a print of the list in SP.
  <a href="https://i.stack.imgur.com/fZibC.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fZibC.gif" alt="Print of the list"></a></p>
  
  <p>What am I missing?</p>