Access to the path is denied .NET Origin: Application & API Last updated 13 Oct 2026

System.UnauthorizedAccessException: Access to the path 'x' is denied

The process’s identity can’t read/write that file or folder — IIS app pool identity, container user, read-only attribute, or a directory passed where a file was expected.

Exact message you may see Access to the path is deniedAccess to the path 'C:\' is denied
Seen on: .NET

Meaning

Apps running under IIS AppPool\Name, a Windows service account, or non-root container users often lack rights to write logs/uploads. Read-only files and trying to open a directory as a file give the same exception.

Common causes

  • App pool/service/container user lacks permission
  • File marked read-only
  • Path is a directory, not a file
  • Writing under Program Files / protected folders

⚡ Quick fix

  1. Grant the app identity rights on the folder
  2. Write to an app-specific data folder
  3. Check the path points to a file

Detailed fix by platform

Windows

  1. icacls C:\inetpub\myapp\App_Data /grant "IIS AppPool\MyAppPool:(OI)(CI)M"

How to diagnose

  1. Identity — Which user runs the app?
  2. Path — File or directory?
  3. Attributes — Read-only?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

0x80070005 — Windows Error 0x80070005 (E_ACCESSDENIED): Access is denied (Windows)0x800700050x80070020 — 0x80070020: The process cannot access the file because it is being used by another process (Windows)0x800700200x80070570 — Error 0x80070570: The file or directory is corrupted and unreadable (Windows)0x80070570403 — HTTP 403 Forbidden (HTTP)403AADSTS65001 — AADSTS65001: The user or administrator has not consented to use the application (Azure)AADSTS65001AccessControlListNotSupported — AccessControlListNotSupported: The bucket does not allow ACLs (AWS)AccessControlListNotS…AccessDeniedException — java.nio.file.AccessDeniedException: /path (Java)AccessDeniedExceptionArgument list too long — bash: /bin/rm: Argument list too long (Linux)Argument list too longAccess to…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.