Reading and displaying an image from a folder I have a question concerning the correctness of the reading and displaying the image in ASP.NET Core MVC web application.

This is the way I am reading image names from a specific folder (I am using IHostingEnvironment _hostingEnvironment to get the rootPath):

   public class GetRandomImageForGalleryView : IGetRandomImageFromFolder
    {
        private string rootPath;
        public GetRandomImageForGalleryView(string rootPath)
        {
            this.rootPath = rootPath;
        }
        public string[] getImage()
        {
            return ReadPhotosFromDirectory();
        }
        private string[] ReadPhotosFromDirectory()
        {

            string[] fileLocations = Directory.GetFiles(rootPath+"\\lib\\Images\\Nature").Select(path =&gt; Path.GetFileName(path))
                                     .ToArray();
            return fileLocations;
        }
    }


And this is the way I am displaying them:

@model IGetRandomImageFromFolder
@{ 
    ViewBag.Title = "Gallery";
}
&lt;div class="container"&gt;
    &lt;div class="row"&gt;
        @{
            foreach (var item in Model.getImage())
            {  
                &lt;img src="~/lib/Images/Nature/@item" style="max-width: 500px;"&gt;
            }
        }
    &lt;/div&gt;
&lt;/div&gt;


Basically I just replace the image name.

Is this a good way? If not, why? Any other remarks would be helpful as well.
You could simplify your getImage() method pretty significantly to just:

public IEnumerable&lt;string&gt; GetImage() =&gt;
    Directory.GetFiles(rootPath + @"\lib\Images\Nature").Select(Path.GetFileName);


Things I changed:


Changed capitalization to follow .Net naming guidelines.
Removed unnecessary method ReadPhotosFromDirectory().
Removed unnecessary variable fileLocations.
Used verbatim string to avoid having to escape backslashes.
Used method group to delegate conversion instead of lambda.
Got rid of ToArray(), which didn't serve any purpose, and changed return type to IEnumerable&lt;string&gt;.
Used C# 6.0 expression bodied method.