2

No matter what I do such as give Network Service and the ASP.NET account full rights to the folder that contains the image, I am still getting this error for a System.IO.File.Move. Anyone know what other accounts I may be missing here? Network Service is the account running the app pool under which this site runs on and I gave Network Service full rights to the entire folder.

I've tried everything. I gave Network Service and the machinename\aspnet full permissions to the folder that contains this .jpg. I'm testing this code and this move on localhost...my developer machine.

PositiveGuy
  • 46,620
  • 110
  • 305
  • 471
  • I have yet to get this working still..tried all that was suggested. – PositiveGuy Dec 15 '09 at 03:00
  • found this which worked: http://codezest.com/archive/2009/12/14/system.unauthorizedaccessexception-access-to-the-path-is-denied.aspx – PositiveGuy Dec 15 '09 at 04:35
  • Thank you, thank you, thank you! Been working on this for 3 hours now with no luck. Changed my Application Pool to use the LocalSystem account and it worked like a charm! – Doug Jan 24 '11 at 20:36

3 Answers3

0

Have you tried using SysInternals FileMon now part of Process Monitor. You can use it to watch for the file access events or the access denied event.

GrayWizardx
  • 19,561
  • 2
  • 30
  • 43
  • yea it says the user trying to create/move is my domain account but it has full rights to that folder that contains the .jpg. It's got as much rights possible so I still can't see why it's preventing the create file issue with the File.Move. – PositiveGuy Dec 15 '09 at 03:23
  • You could try granting the "Everyone" account full access to that folder, or try moving the folder to be a subfolder of the folder where the ASPX pages reside. The second one is obviously less of a security risk. – GrayWizardx Dec 15 '09 at 04:29
0

It might be because you write into some other folder that is not under the ASP.NET application (eg %TEMP% folder or something). In this case the account used is IUSR_MACHINENAME which represents anonymous user.

You either need to impersonate, use another folder or give write privileges to IUSR_XXX (which I don't think is a good idea) to deal with that.

Dmytrii Nagirniak
  • 23,696
  • 13
  • 75
  • 130
0

On the machine hosting the shared drive, make sure to set things up under both these tabs:

  • Sharing -> Permissions
  • Security

Most of us deal with the Security tab for getting IIS stuff working, but it was the former that was giving me the same issue with the .MoveTo() method. (It could read, just not move).

To further complicate matters, I also had the directory shared as multiple names - make sure to check the permissions for each shared name.

Overflew
  • 7,872
  • 10
  • 45
  • 65