Reputation: 11
I want to Show a link to all files in a folder. How do you do that in ASP.NET Razor code in WebMatrix. You can show all entries in a database with an
@foreach (var row in db.Query(selectQueryString))
but I'm not sure how to do that by pulling all files from a folder.
Upvotes: 1
Views: 2594
Reputation: 100537
Directory.GetFiles will give you list of files in given directory.
Note: beware of security issues exposing and accessing files in ASP.Net environment.
Upvotes: 2
Reputation: 11201
You can achieve it by the example shown below
@foreach(var fileName in Directory.GetFiles("."))
{
.....
}
Upvotes: 1