简体   繁体   中英

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'

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:

“本地用户”经理

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM