title: How do I create folders in ASP.NET in code behind?
body: <p>I want to create dynamic folders at run time.  Folder names with be input via a TextBox and output will be displayed in a TreeView. </p>
  
  <p>The form will submit if I enter the first folder name into textbox1 and click the "Add Folder" button.  When I submit multiple folders with the same name the output should be an indexed increment of the name. Eg. FooFolder, FooFolder(2), FooFolder(3), etc.</p>
  
  <p>If I delete FooFolder(2) and then recreate a folder with the name FooFolder, the folder should be FooFolder(2), and if I create one more folder then it should be FooFolder(4).</p>
  
  <p>For deletion one can select the particular folder from the TreeView which will be displayed in TextBox2 and click the "Remove Folder" button.</p>
  
  <p>Here is my presentation code:</p>
  
  <pre><code>&lt;asp:Button ID="btnAddFolder" runat="server" Height="24px" Text="Add Folder" 
          Width="148px" onclick="btnAddFolder_Click" /&gt;
      &lt;asp:TextBox ID="TextBox1" runat="server"&gt;&lt;/asp:TextBox&gt;
      &lt;br /&gt;
      &lt;asp:Button ID="btnRemoveFolder" runat="server" Text="Remove Folder" /&gt;
      &lt;asp:TextBox ID="TextBox2" runat="server"&gt;&lt;/asp:TextBox&gt;
      &lt;br /&gt;
      &lt;br /&gt;
      &lt;asp:TreeView ID="TreeView1" runat="server" ImageSet="XPFileExplorer" 
          NodeIndent="15"&gt;
          &lt;ParentNodeStyle Font-Bold="False" /&gt;
          &lt;HoverNodeStyle Font-Underline="True" ForeColor="#6666AA" /&gt;
          &lt;SelectedNodeStyle BackColor="#B5B5B5" Font-Underline="False" 
              HorizontalPadding="0px" VerticalPadding="0px" /&gt;
          &lt;NodeStyle Font-Names="Tahoma" Font-Size="8pt" ForeColor="Black" 
              HorizontalPadding="2px" NodeSpacing="0px" VerticalPadding="2px" /&gt;
      &lt;/asp:TreeView&gt;
  </code></pre>
  
  <p>Now how do I write the code to do the work?</p>