user603007
user603007

Reputation: 11794

save xml file results in System.UnauthorizedAccessException:

I am trying to save xml to a certain location like this:

private void UpdateXMLFile(XElement xmlFeed,string xmlFileLocation)
{
            xmlFeed.Save(xmlFileLocation);
}

I have added SYSTEM, NETWORK SERVICE and Administrators all with all permissions to the folder I am saving in but I still get this error?

System.UnauthorizedAccessException Access to the path 'c:\temp\myfile.xml' is denied

I am using an asp.net 3.5 application (iis 7) to do this. The identity of the application is the 'ApplicatonPoolIdentity'

Upvotes: 0

Views: 1134

Answers (2)

Piotr Stapp
Piotr Stapp

Reputation: 19830

In my options there are two possibilities:

  1. You did not grant write permission to IIS APPPOOL user. The problems can occur when you have non-Windows integrated authentication enaled in Web.Config
  2. You have to grant write permission to every user which is using your site if you have Windows integrated authentication

Upvotes: 0

avs099
avs099

Reputation: 11227

you need to add write permissions for user IIS APPPOOL\[your app pool name] to that folder. This user is created "under the hood" when you create an app pool, and you can find them in your "local users" manager:

"local users" manager

Upvotes: 2

Related Questions