My ASP.NET Web forms project has got a folder called "inc" in it and inside there's another folder called "drinks" with images inside. So the absolute path would be something like ~/inc/drinks/.
I'm trying to get all the file names in that exact folder using this function:
private static string getImageNames(string imgPath)
string names = Directory.GetFiles(imgPath) // <- exception
.Select(path => Path.GetFileName(path))
Could not find a part of the path 'C:\Program Files (x86)\inc\drinks'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Program Files (x86)\inc\drinks'.
Change it to
See this answer for more details on Server.MapPath