title: C# - Create a tree structure of a flat list (by dates)
body: <p>I have a list with many files. I want to show this list in a tree structure instead of a flat list.
  Something like this:</p>
  
  <pre><code>2001
  - 2001-01
      -2001-01-01
          -File 1
          -File 2
          -File 3
          -File 4
      -2001-01-02
          -File 5
          -File 6
          -File 7
          -File 8
      -2001-01-03
          - etc
      -2001-01-03
  etc...
  </code></pre>
  
  <p>I found something similar but dont know how to apply it with my settings.
  <a href="https://stackoverflow.com/questions/444296/how-to-efficiently-build-a-tree-from-a-flat-structure">How to efficiently build a tree from a flat structure?</a></p>
  
  <p>The files have a DateTime field where I get the date.</p>
  
  <p>Can I group all my files with the same date?</p>
  
  <p>edit:
  Right now the list is displayed like this</p>
  
  <pre><code>2001-01-01 - File 1
  2001-01-01 - File 2
  2001-01-01 - File 3
  2001-01-01 - File 4
  2001-01-02 - File 5
  2001-01-02 - File 6
  2001-01-02 - File 7
  etc
  </code></pre>