How we can add write access to a directory programmatically in C#?

吃可爱长大的小学妹 提交于 2019-12-01 05:21:07

问题


I have an ASP.NET page that creates directories, and in another page I upload some files in these folders, but when I upload a file in a directory, the below error appears:

Access to the path 'my path' is denied.

回答1:


Your code is running under a user account that does not have write access to the specified directory, so it is unlikely that same user would have access to change the permissions. This means that you will not be able to change the permissions from your code while it is running under that context. Remember that the code can do no more (permissions wise) than the user account allows.

You will need to set the permissions on the directory (or a parent directory) manually so that the ASP.NET user can write to it.




回答2:


if you are using iis6 you need to grant the aspnet user permissions to that folder. if you are using iis7 you need to grant the IIS_IUSRS user permissions to that folder.



来源:https://stackoverflow.com/questions/4085630/how-we-can-add-write-access-to-a-directory-programmatically-in-c

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