Access to the path is denied

I’m trying to save an image to a folder in .NET C# but I get this exception:

Access to the path 'C:\inetpub\wwwroot\mysite\images\savehere' is denied.The error occured at mscorlib because    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)

I gave full control to this folder (savehere) to network service and iis_iusrs, even gave full control to everyone but still getting this exception.
I tried to give access via explorer and via IIS manager, still no luck

I’m doing it on Windows server 2008 R2 and IIS 7.5, Who do I need to give access?

25 Answers
25

Leave a Comment