What I want to do is display the contents of a folder that is on my server in a view in my MVC application.
I have something that, it seems to me, 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 anyone could point in the right direction. (and also, if someone thinks that my action could be improved, advice would be welcome :))
Here is the action:
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 => f.Name).ToArray(); var salesFiles = files.Where(f => f.Extension == ".xls" || f.Extension == ".xml"); return View(salesFiles); }
Any help would be appreciated, thanks :)
source share