My development server is called the WebApp which has the following folders as shown in the image. I want to write a method/function to access the 'Images' folder inside the controller while the application is running

enter image description here

1 Answers

kristech On Best Solutions

You need to get the path to the folder and then can access each file in the folder. Try this:

string path = Server.MapPath("~/Images/");
DirectoryInfo dirInfo = new DirectoryInfo(path);
FileInfo[] files = dirInfo.GetFiles();

foreach(FileInfo file in files)
    string fileName = file.Name;