Debugging locally on Windows 10 machine, VS2015.
I need to open a file with Read access only. That file exists in a sub-folder of the web application.
This throws an exception:
System.UnauthorizedAccessException: Access to the path 'F:\webroot\subfolder' is denied.
I have tried adding Everyone with Full Permissions, adding every user with Full Permissions, turning on security policy auditing and checking the Security log to uncover the requesting user but nothing appears in there as if it is not actually a security error, a different folder name, and everything else I can find online including adding the ASPNET user - there is no such user to add.
The calculated path is the correct physical disk path. The path is inside the webroot.
string FilePath = HttpContext.Current.Server.MapPath("\\Upload"); string PathToFile = FilePath + "\\" + idFileName; Stream fs = File.Open(FilePath, FileMode.Open, FileAccess.Read); The final line of code throws the exception.
ASP.NET web page output: Access to the path 'F:\webrootname\Upload' is denied.
Application Event Log:
Event code: 4011 Event message: An unhandled access exception has occurred.
PathToFileanywhere...