title: Get file information from recursive folders
body: <p>What I'd like to do is get 6 pieces of file information from every file in a folder, and all folders beneath it.  These pieces are:</p>
  
  <ul>
  <li>Type (you can do this in Access, it will return "Microsoft Excel Worksheet" or "Winzip File" or something, just like you see in the Explorer window, but I didn't see a property for this in C#)</li>
  <li>FullName</li>
  <li>Length</li>
  <li>CreationTime</li>
  <li>LastAccessTime</li>
  <li>LastWriteTime</li>
  </ul>
  
  <p>I have the following code, which will spit out a list of files complete with path, but I'm trying to figure out how to get that additional info in my output.  If it can be separated by a semicolon or something, that would be good as the eventual desire is to write this info to a table.  Any help is appreciated.</p>
  
  <pre><code>    private void GetMyFiles () {
          string rootDirectory = @"" + txtPathToScan.Text + "";
          string extension = "*";
  
          List&lt;string&gt; files = GetFilesRecursively (rootDirectory, extension);
  
          Console.WriteLine ("Got {0} files of extension {1} in directory {2}", files.Count, extension, rootDirectory);
          foreach (string file in files) {
              Console.WriteLine (file);
          }
      }
  
      /// &lt;summary&gt;
      /// This function calls itself recursively for each of the subdirectories that it finds
      /// in the root directory passed to it. It returns files of the extension as specified
      /// by the caller.
      /// &lt;/summary&gt;
      /// &lt;param name="rootDirectory"&gt;The directory from which the file list is sought.&lt;/param&gt;
      /// &lt;param name="extension"&gt;The particular extension for which the file list is sought.&lt;/param&gt;
      /// &lt;returns&gt;A list of all the files with extension as specified by the caller. This list
      /// includes the files in the current directory as well its sub-directories.&lt;/returns&gt;
      static List&lt;string&gt; GetFilesRecursively (string rootDirectory, string extension) {
          // Uncomment this line only if you want to trace the control as it goes from
          // sub-directory to sub-directory. Be ready for long scrolls of text output:
          //Console.WriteLine ("Currently in directory {0}", rootDirectory);
  
          // Create an output list:
          List&lt;string&gt; opList = new List&lt;string&gt; ();
  
          // Get all files in the current directory:
          string[] allFiles = Directory.GetFiles (rootDirectory, "*." + extension);
  
          // Add these files to the output list:
          opList.AddRange (allFiles);
  
          // Get all sub-directories in current directory:
          string[] subDirectories = Directory.GetDirectories (rootDirectory);
  
          // And iterate through them:
          foreach (string subDir in subDirectories) {
              // Get all the files from the sub-directory:
              List&lt;string&gt; subDirFileList = GetFilesRecursively (subDir, extension);
              // And add it to this list:
              opList.AddRange (subDirFileList);
          }
  
          // Finally return the output list:
          return opList;
      }
  </code></pre>