.NET MVC Access denied when trying to create Directory

╄→尐↘猪︶ㄣ 提交于 2019-12-25 07:26:57

问题


I am trying to create a Directory in .NET using Directory.CreateDirectory, I followed the directions here to give access permission but I am still getting an UnauthorizedAccessException. Does anyone have any advice? Note, this is a web application that uses the IIS7 server.


回答1:


In the directory you are attempting to create a new directory, make sure that your app pool user has Read/Write permissions for that directory. You have to specifically do that in addition to adding the user to the user groups.




回答2:


2 more potential issues (+1 to user959729):

  • you are creating directory at different place than you think you are (i.e. you building path wrong)
  • the code runs under impersonated account (user's or anonymous) and such user does not have permissions to create folder (to verify try check System.Environment.UserName before creating directory). To fix you need to run code as process account.


来源:https://stackoverflow.com/questions/14265471/net-mvc-access-denied-when-trying-to-create-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!