Upload images acces to path denied
<p>Hi I seem to be having a problem when uploading images in asp.net.When I tryed to upload an Image I get this error:</p>

<blockquote>
  <p>Access to the path 'D:\Projects IDE\Visual Studio\MyWork\Websites\Forum\Images\avatar\userAvatars\aleczandru' is denied.</p>
</blockquote>

<p>I have set application pools Identoty to NETWORKSERVICE ando also added the NETWORK SERVICE account to the Images folder with full permision but I still get the same error.</p>

<p>This is my code:</p>

<pre><code>private void addImageToApp()
{
    string path = "~/Images/avatar/userAvatars/" + User.Identity.Name;

    createPath(path);
    if( Directory.Exists(HostingEnvironment.MapPath(path)))
    {
        //try {
              UploadImage.SaveAs(HostingEnvironment.MapPath(path));
          //    MultiViewIndex.ActiveViewIndex = 0;
        //}catch(Exception ex)
        //{
          //     AvatarDetails.Text = ex.Message;
        //}  
    }
}

private void createPath(string path)
{  
    string activeDir = HostingEnvironment.MapPath("~/Images/avatar/userAvatars");
    if( !Directory.Exists(Server.MapPath(path)) )
    {
        string newPath = Path.Combine(activeDir, User.Identity.Name);
        Directory.CreateDirectory(newPath);
    }
}
</code></pre>

<p>What else can I do to solve this problem?</p>

<p><strong>EDIT</strong></p>

<p>Hi at this point I have full permision control to the following USERS:</p>

<ul>
<li>Authetificated Users</li>
<li>IUSR</li>
<li>SYSTEM </li>
<li>NETWORK SERVICE </li>
<li>IIS_WPG</li>
<li>Administrator</li>
<li>USers</li>
</ul>

<p>Is it posible that I need to set any configuration to IIS in order for this to work?</p>

<p><strong>EDIT</strong></p>

<p>I have messed around with SQL-SERVER for the last couple of days in order to make this work so I might have missconfigured something form what I understand NETWORK SERVICE is stored in SQL-SERVER master.db database.I seem to be having two network service logins may this be the problem?I remember when I first checked it I had none now I have two:</p>

<p><img src="http://i.stack.imgur.com/DnevB.gif" alt="enter image description here"></p>

<p><strong>EDIT</strong></p>

<p>This is the print with the permisions I added to the folder:</p>

<p><img src="http://i.stack.imgur.com/oicvu.gif" alt="enter image description here"></p>

<p><strong>EDIT : Complete error</strong></p>

<p><img src="http://i.stack.imgur.com/pNv7N.gif" alt="enter image description here"></p>

<p>StackTrace:</p>

<p><img src="http://i.stack.imgur.com/QeyXZ.gif" alt="enter image description here"></p>
