title: C# treeView is there is an code to arrange an child node to be the last child node from its parent
body: <p>i am using treeView to show sequence directory and its subdirectory and files in the treeView on form and i use the following method to load the tree view </p>
  
  <p>in form load : </p>
  
  <pre><code>        treeView1.Nodes.Clear();
          toolTip1.ShowAlways = true;
          LoadDirectory("C:\\Windows\\System32\\" + inventedName );  
  </code></pre>
  
  <p>and the following 3 methods to load directory and subdirectory and files</p>
  
  <pre><code>    public void LoadDirectory(string Dir)
      {
  
          DirectoryInfo di = new DirectoryInfo(Dir);
  
          TreeNode tds = treeView1.Nodes.Add(di.Name);
  
          tds.Tag = di.FullName;
          //tds.StateImageIndex = 0;
          tds.ImageIndex = 0;
          tds.StateImageIndex = 0;
          tds.SelectedImageIndex = 0;
          LoadFiles(Dir, tds);
          LoadSubDirectories(Dir, tds);
      }
  
      private void LoadSubDirectories(string dir, TreeNode td)
      {
  
          string[] subdirectoryEntries = Directory.GetDirectories(dir);          
  
          // Loop through them to see if they have any other subdirectories  
          foreach (string subdirectory in subdirectoryEntries)
          {
  
              DirectoryInfo di = new DirectoryInfo(subdirectory);
              TreeNode tds = td.Nodes.Add(di.Name);
              renameNodes(tds);    
              //tds.StateImageIndex = 0;
              tds.Tag = di.FullName;
              tds.ImageIndex = 0;
              tds.StateImageIndex = 0;
              tds.SelectedImageIndex = 0;
              LoadFiles(subdirectory, tds);
              LoadSubDirectories(subdirectory, tds);
  
          }
      }
  
      private void LoadFiles(string dir, TreeNode td)
      {
          string[] Files = Directory.GetFiles(dir, "*.pdf");
  
          // Loop through them to see files  
          foreach (string file in Files)
          {
              FileInfo fi = new FileInfo(file);
              TreeNode tds = td.Nodes.Add(fi.Name);
              tds.Tag = fi.FullName;
              tds.ImageIndex = 1;
              tds.StateImageIndex = 1;
              tds.SelectedImageIndex = 1;
  
          }
      }
  </code></pre>
  
  <p>my problem is the subdirectories (folder) have specific names i can not change it 
  for example : </p>
  
  <pre><code>&gt; root 
      &gt; parent 
            &gt; 1.0 xxx
            &gt; 1.10 xxx
            &gt; 1.2 xxx
            &gt; 1.3 xxx 
            &gt; 1.4 xxx
            &gt; 1.5 xxx
            &gt; 1.6 xxx
            &gt; 1.7 xxx
            &gt; 1.8 xxx
            &gt; 1.9 xxx
  </code></pre>
  
  <p>but i need it to be like that </p>
  
  <pre><code>&gt; root 
      &gt; parent 
           &gt; 1.0 xxx
           &gt; 1.2 xxx
           &gt; 1.3 xxx 
           &gt; 1.4 xxx
           &gt; 1.5 xxx
           &gt; 1.6 xxx
           &gt; 1.7 xxx
           &gt; 1.8 xxx
           &gt; 1.9 xxx
           &gt; 1.10 xxx 
  </code></pre>
  
  <p>the stupid (1.10 xxx) child must be after (1.9 xxx) child 
  and as i told i can not rename the folder that will be wrong is there is any way to send it to be the last child</p>
  
  <p>thanks for helping me</p>