Reputation: 169
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
Upvotes: 2
Views: 1287
Reputation: 1066
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;
}
Upvotes: 4