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

后端 未结 2 1314
-上瘾入骨i
-上瘾入骨i 2021-01-13 15:21

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:<

2条回答
  •  孤街浪徒
    2021-01-13 16:25

    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.

提交回复
热议问题