Click here to Skip to main content
14,216,449 members
Rate this:
Please Sign up or sign in to vote.
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
Rate this:
Please Sign up or sign in to vote.

Solution 2

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.
   
Comments
Monjurul Habib 29-Apr-11 14:13pm
   
nice link. my5.
Rate this:
Please Sign up or sign in to vote.

Solution 1

Check you access permissions to the folder.
give the proper permissions to the folder using security tab from properties window
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

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.
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100