title: MVC Display Files from a Folder in a View
body: <p>What I'm looking to do, is display the contents of a folder which is located on my server in a View in my MVC application. </p>
  
  <p>I have what I think should be in place for the Action, however I'm a little unsure how to go about implementing the corresponding view and I was wondering if someone could point be in the right direction on that. (and also, if someone thinks my Action could be improved, advice would be welcome :) )</p>
  
  <p>Here is the action:</p>
  
  <pre><code>public ActionResult Index()
          {
              DirectoryInfo salesFTPDirectory = null;
              FileInfo[] files = null;
  
              try
              {
                  string salesFTPPath = "E:/ftproot/sales";
                  salesFTPDirectory = new DirectoryInfo(salesFTPPath);
                  files = salesFTPDirectory.GetFiles();
              }
              catch (DirectoryNotFoundException exp)
              {
                  throw new FTPSalesFileProcessingException("Could not open the ftp directory", exp);
              }
              catch (IOException exp)
              {
                  throw new FTPSalesFileProcessingException("Failed to access directory", exp);
              }
  
              files = files.OrderBy(f =&gt; f.Name).ToArray();
  
              var salesFiles = files.Where(f =&gt; f.Extension == ".xls" || f.Extension == ".xml");
  
              return View(salesFiles);
          }
  </code></pre>
  
  <p>Any help would be appreciated, thanks :)</p>