I've an XML file stored in App_Data which is only used to read some configuration on startup. When I attempt to open it within my code, I get an Access to the path ... is denied message.
I'm having trouble understanding why, and how to solve it. I guess in theory I should alter the permissions on the file (and directory), but this hasn't changed anything.
To give a bit more background:
1. Its a file bundled with the project, so the setup created by VS2008 writes it to the correct place during install. I didn't think I'd need to do anything unusual post install such that the ASP.NET application would have access.
2. When I've tried publishing this locally, I've not had any problems. - This is only on a test Windows 2003 server.
3. I've ran a simple page to understand the effective user of IIS - It is NT AUTHORITY\NETWORK SERVICE. I tried granting "Full Access" to this user to this file, and still it doesn't work.
The code to open it is simple:
FileStream fs = new FileStream(Server.mapPath(s), FileMode.Open);
Actually, I think I found it. I needed to open the file as follows:
new FileStream(Server.MapPath(s), FileMode.Open, FileAccess.Read);