Access to the Path... is denied

When your ASP.NET application tries to access a file in a folder, you may get an error message saying "Access to the path <file path> is denied.".  To solve this problem, you will need to provide permissions for NETWORK SERVICE (Windows 2003/2008) or ASPNET (Windows XP) account to access the folder containing that file.  To provide the permissions, do the following:

  1. Right click on the folder and select Properties.
  2. Go to Security tab (if it doesn't appear, see below) and click on the Edit... button under Group or user names section.
  3. Click on the Add... button and, on the popup window (titled Select Users or Groups), click on the Advanced... button.
  4. Click on the Find Now button.
  5. Select NETWORK SERVICE (or ASPNET) account and click OK twice to go back to the permissions window.
  6. On the Permissions window, select the account and check Allow for Full Control.
  7. Click OK twice to close the Properties window.

Now your ASP.NET should have an access to the folder.

What if the Security tab doesn't show up?

You'll need to uncheck the Simple File Sharing option in folder options.

  1. On the Tools menu of your windows explorer, select Folder Options.
  2. On the View tab, scroll down until you find the option saying "Use Simple File Sharing (recommended)".
  3. Uncheck it and click OK to accept the change.

Now the security tab should appear and you can start configuring the permissions as stated above.