title: C# display all files from selected folder
body: <p>I want to display all the files from a selected folder.. ie files from that folder and files from the subfolders which are in that selected folder.</p>
  
  <p>example - </p>
  
  <p>I have selected D:\Eg. Now I have some txt and pdf files in that. Also I have subfolders in that which also contain some pdf files. Now I want to display all those files in a data grid.</p>
  
  <p>My code is </p>
  
  <pre><code>public void  selectfolders(string filename)
  {      
       FileInfo_Class fclass;
       dirInfo = new DirectoryInfo(filename);
  
       FileInfo[] info = dirInfo.GetFiles("*.*");
       foreach (FileInfo f in info)
       {
  
          fclass = new FileInfo_Class();
          fclass.Name = f.Name;
          fclass.length = Convert.ToUInt32(f.Length);
          fclass.DirectoryName = f.DirectoryName;
          fclass.FullName = f.FullName;
          fclass.Extension = f.Extension;
  
          obcinfo.Add(fclass);  
       }
       dataGrid1.DataContext = obcinfo;
  } 
  </code></pre>
  
  <p>What to do now? </p>