C# MVC Access to path denied when trying to write file
Solution 1
I am not running IIS, I am running the watered down version "ASP.NET Development Server". So I am quite limited
The problem is that in order for you to write to the file directory from the application you will need to run Visual Studio as Administrator.
Windows 7 is preventing the process from going outside of its sandbox because it is running with limited privileges. This is true even if your account is the administrator.
Solution 2
Check the permissions of the parent folder and make sure they are inheritable, you can check this on the advance options window.
Solution 3
This might help a bit... probably application pool permission is the culprit here:
IIS AppPoolIdentity and file system write access permissions
Related videos on Youtube
TheGuest
Updated on June 04, 2022Comments
-
TheGuest almost 2 years
I have an MVC application in which users are able to upload files. Before I write the uploaded file, I create a directory according to date time. I start off with
C:\ApplicationName
and end up withC:\ApplicationName\20111001\Filename.ext
when the upload is completed (in theory).My problem on my local Windows 7 machine is that I can not write the file.
I get an
"access denied"
exception no matter which user I give full access to the directory. The strange thing is that the date directory gets created just fine.I have given the following users full access:
- [Current logged in user]
- NETWORK SERVICE
- IUSR
- IIS_IUSRS
- Guests
- Everyone
Without any success. I really don't understand what is going on here. When I give Everyone full access, I should be able to create a file right?
PS: I use Visual Studio 2010 and ASP.NET Development Server straight out of the box.
-
TheGuest over 12 yearsI have tried that, but I still get the "Access denied" exception.
-
TheGuest over 12 yearsI am not running IIS, I am running the watered down version "ASP.NET Development Server"
-
TheGuest over 12 yearsI am not running IIS, I am running the watered down version "ASP.NET Development Server". So I am quite limited.