0
Does anyone know how to iterate through images in a directory in asp.net razor pages?
2 odpowiedzi
+ 2
To iterate through images in a directory in ASP.NET Razor Pages, you can use the Directory.GetFiles method to get a list of file paths in the directory, and then iterate over the list using a foreach loop.
Here is an example of how you can do this:
@{
// Get the path to the directory containing the images
var directoryPath = "path/to/directory";
// Get a list of files in the directory
var imageFilePaths = Directory.GetFiles(directoryPath);
}
<ul>
@foreach (var imageFilePath in imageFilePaths)
{
<li>
<img src="@imageFilePath" />
</li>
}
</ul>
0
Thanks Calvin! Will check it out!