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.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 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.
Method 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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0