Directory.CreateDirectory Method throws UnauthorizedAccessException

  • Thread starter Thread starter GM
  • Start date Start date
G

GM

Any help is greatly appreciated! I'm up against a meeting deadline.

Directory.CreateDirectory Method throws UnauthorizedAccessException

Here is the path:

"C:\JumpStart\JumpStart\sites\Proto\images\sites.e-Plaza.org\Alece"

Everything before 'Alece' already exists.

I've tried the following:

For parent directory:
C:\JumpStart\JumpStart\sites\Proto\images\sites.e-Plaza.org

Set security permissions for ASP.NET to 'Modify' (and even full control)
Set security permissions for ISUR-server to 'Modify' (and even full control)

Set UNC share permissions of 'JumpStart' (parent) to 'Write'

Set IIS permissions for 'images' directory and subs to 'Write'

Still I get 'UnauthorizedAccessException'

THANKS!
Gary
 
Yes, This error makes sense. ASP.NET application runs under ASPNET account by default. IIS setting might allow users to write, but Windows security doesn't allow ASPNET user to do so.
2 possible solutions

1. Give ASPNET user more control; add him to User or Poweruser group. This might not be the best solution if security is your concern
2. Enable Win authentication on this site. Then enable impersonation in web.config file. This solution will work if it's an Intranet type application
 
Whoops! I had quotation marks around the variable defining the path.
No amount of permissions were going to allow creating a "ImgDir" path.
 
Back
Top