title: Creating Folders programmatically in SharePoint 2013
body: <p>Currently I have code that creates a Folder in the <code>Documents</code> directory when run:</p>
  
  <pre><code>using (var context = new Microsoft.SharePoint.Client.ClientContext(sharePointSite))
  {
      context.Credentials = new Microsoft.SharePoint.Client.SharePointOnlineCredentials(user, password);
  
      Web web = context.Web;
  
      Microsoft.SharePoint.Client.List docs = web.Lists.GetByTitle(&lt;upper level folder&gt;);
      docs.EnableFolderCreation = true;
  
      docs.RootFolder.Folders.Add(folderName);
  
      context.ExecuteQuery();
  
      return true;
  }
  </code></pre>
  
  <p>I am having troubles creating sub folders in folders that I have created using this code already. So like if I wanted to create a folder called <code>Feb</code> under <code>Documents</code> this would do that. But if I wanted to create a folder called <code>Week 2</code> under the new folder <code>Feb</code>. It won't do that. I get this error:</p>
  
  <p><code>{"List 'Feb' does not exist at site with URL 'https://my.sharepoint.com/sites/labels'."}</code></p>
  
  <p>I realize that the problem is probably <code>docs.RootFolder.Folders.Add(folderName);</code> because <code>Feb</code> wouldn't be the root folder and when it looks for it an exception would be thrown. </p>
  
  <p>So I was hoping that someone could help me out with some code to add sub folders to already created folders. I am using Visual Stuidos 2010 and can't upgrade to 2012 otherwise I would. I have the 2013 <code>Microsoft.Sharepoint.Client</code> dll's that can be referenced in VS 2010. </p>