0

While developing inside VS2013 using the built in IIS Express Web Server I created a Documents folder within my Application folder to upload files to. When trying to save a file I am using:

string uploadedFile = @"C:\dev\myApps\Application1\Documents\uploadedFile.pdf";
file.SaveAs(uploadedFile );

I added full control permissions to the Documents folder for IIS_IUSRS, NETWORK, NETWORK SERVICE. Still nothing.

JTunney
  • 914
  • 1
  • 15
  • 46

1 Answers1

1

Try this:

"Access to the path 'xxxxxx' is denied."

As error says you need to assign permissions to folders

  1. Right Click Folder
  2. Go to Security Tab
  3. Click on Edit
  4. Click on Add
  5. Click on Advanced
  6. Find Now
  7. Give Permission to IIS_IUSRS (Full Control)
  8. Click On OK
  9. Click On OK
  10. Click On Full Control in allow
  11. Click On OK
  12. Again Run the Application

Note: if the above steps are not working, then try to give same permission to NETWORK, NETWORK SERVICE users

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Dgan
  • 10,077
  • 1
  • 29
  • 51
  • Hmm there are 2 project properties called 'Anonymous Authentication = Enabled' and 'Windows Authentication = False' Could these have anything to do with it? – JTunney Mar 08 '15 at 14:26
  • @user2272527 where you got theses kind of properties ?? Or These properties are not required to solve your problem. You need to give only access permission to `IIS_IUsers` for writing your files to Directory – Dgan Mar 08 '15 at 14:33
  • I am still getting the same error after adding myPCname\IIS_IUsers and also NETWORK SERVICE to have full control. Do I need to add them to my projects directory rather than just my document's directory within my project directory? One other thing to note is that after running my web app in the debugger it keeps forcing Read Only on my Documents folder. – JTunney Mar 08 '15 at 14:35
  • The properties I was talking about are shown when you highlight your Webforms project name in the solution explorer. I feel like my Anonymous user doesn't have permission to access the directory. – JTunney Mar 08 '15 at 14:42
  • refer this : http://stackoverflow.com/questions/19724297/asp-net-getting-the-error-access-to-the-path-is-denied-while-trying-to-upload http://stackoverflow.com/questions/4877741/access-to-the-path-is-denied http://stackoverflow.com/questions/4340074/access-to-the-path-denied-when-uploading-excel-file – Dgan Mar 08 '15 at 14:45
  • Still nothing. Does it have anything to do with my Webapps being in a custom folder? C:/dev/WebApps/MySite/Documents is the path. I am starting to think I need to add IIS_IUSRS to the MySite folder. – JTunney Mar 08 '15 at 14:56
  • My project is asp.net mvc based in my local pc and i am using iis express only. There is no virtual directly created by me. does not solved my problem i am getting - System.UnauthorizedAccessException – yogihosting Jun 30 '15 at 11:46