In my MVC application I have the following paths;
How would I, in my c# controller, get a l
.NET 4.0 has got a more efficient method for this:
Directory.EnumerateFiles(Server.MapPath("~/Content/images/thumbs"));
You get an IEnumerable<string>
on which you can iterate on the view:
@model IEnumerable<string>
<ul>
@foreach (var fullPath in Model)
{
var fileName = Path.GetFileName(fullPath);
<li>@fileName</li>
}
</ul>
Directory.GetFiles("/content/images/thumbs")
That will get all the files in a directory into a string array.