Click here to Skip to main content
15,924,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When we write XML file then XmlWriter exception

System.UnauthorizedAccessException: Access to the path 
'D:\WorldMap\EXnetherlands_data.xml' is denied.
 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) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) at System.Xml.XmlTextWriter..ctor(String filename, Encoding encoding)
Posted
Updated 29-Apr-11 1:26am
v2

Hi,

he problem is that IIS user or NETWORK SERVICE user need to have permissions to write the file to destination folder location. Follow the link below to know how to add permission to that folder.
http://vijaymodi.wordpress.com/2007/12/28/aspnet-access-to-the-path-cinetpubwwwroottestimagesuploadtestjpeg-is-denied/[^]

Hope this will help.
 
Share this answer
 
Comments
Monjurul Habib 29-Apr-11 14:13pm    
nice link. my5.
Check you access permissions to the folder.
give the proper permissions to the folder using security tab from properties window
 
Share this answer
 
When you are writing in a file on the server, you need to have appropriate write permission to the account processing the request on the directory that you are using to access the file.

Either provide the write permission to the user (generally ASPNET user) or to the user account that is impersonating the calls.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900