title: Populate TreeView with file system directory structure
body: <p>i am new with Nodes here.. :) i came up with this algorithm but it only shows the list of parent nodes.. like this..</p>
  
  <pre><code>a
     a.txt
     b
     c
  c
     m
     n
  b
     o
     p
  etc...
  </code></pre>
  
  <p>i want the next node will be put in one of the node inside the previous node.. so it will come up like this..</p>
  
  <pre><code>a
     a.txt
     b
        o
        p
     c
        m
        n
  etc...
  </code></pre>
  
  <hr>
  
  <p>i have some ideas in mind but i can implement it to codes.. :) any help please..</p>
  
  <pre><code>private void ListDirectory(TreeView treeView, String path)
  {            
      Stack&lt;string&gt; stack = new Stack&lt;string&gt;();
      TreeNode DirFilesCollection = new TreeNode();
  
      stack.Push(path);            
  
      while (stack.Count &gt; 0)
      {
          string dir = stack.Pop();
          try
          {
              List&lt;String&gt; parentDir = new List&lt;string&gt;();
              parentDir.AddRange(Directory.GetFiles(dir, "*.*"));
              parentDir.AddRange(Directory.GetDirectories(dir));
  
              DirectoryInfo d = new DirectoryInfo(dir);
              TreeNode TParent = new TreeNode(d.Name);
  
              foreach (String s in parentDir)
              {
                  FileInfo f = new FileInfo(s);
                  TreeNode subItems = new TreeNode(f.Name);
  
                  TParent.Nodes.Add(subItems);
              }
  
              DirFilesCollection.Nodes.Add(TParent);
  
              foreach (string dn in Directory.GetDirectories(dir))
              {
                  stack.Push(dn);
              }
          }
          catch
          {}
      }
  
      Action clearTreeView = () =&gt; treeView.Nodes.Clear();
      this.Invoke(clearTreeView);
  
      Action showTreeView = () =&gt; treeView.Nodes.Add(DirFilesCollection);
      this.Invoke(showTreeView);
  }
  </code></pre>