You still haven't told us what the error is, but at a guess, it probably comes from these two lines:
Quote:
string source = "~/Content/Images/";
string[] fileEntries = Directory.GetFiles(source);
The
Directory.GetFiles
method expects the physical path to the folder. You are passing in an app-relative virtual path. Since the
GetFiles
method knows nothing about ASP.NET applications, you will most likely get a
DirectoryNotFoundException
.
To fix that, you need to map the virtual path to a physical path:
string source = "~/Content/Images/";
string physicalPath = System.Web.Hosting.HostingEnvironment.MapPath(source);
string[] fileEntries = Directory.GetFiles(physicalPath);
NB: This sort of code really belongs in the controller, not the view.