title: UnauthorizedAccessException trying to delete a file in a folder where I can delete others files with the same code
body: <p>I'm getting a Unauthorized Access Exception </p>
  
  <ul>
  <li>in a file which I can delete manually. </li>
  <li>in a folder where I'm able to delete by code other files </li>
  <li>and the file isn't marked as read only</li>
  <li>besides, I'm using Windows XP in a standalone PC and I have not assigned any permissions to the folder or the file.</li>
  <li>no other process is using the file</li>
  </ul>
  
  <p>If it helps, this is the code where the exception ocurrs:</p>
  
  <pre><code>protected void DeleteImage(string imageName)
  {
      if (imageName != null)
      {
          string f = String.Format("~/Images/{0}", imageName);
          f = System.Web.Hosting.HostingEnvironment.MapPath(f);
          if (File.Exists(f))
          {
              if (f != null) File.Delete(f);
          }
      }
  }
  </code></pre>
  
  <p>Why could this happen?</p>