UnauthorizedAccessException: Can't write to file, but I can read i

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Lukeb (Lukeb_at_discussions.microsoft.com)
Date: 09/03/04


Date: Fri, 3 Sep 2004 06:15:03 -0700

Hello
I've just developed an application in VS on my machine (w2k), c#.
Everything worked just fine, but when i installed the web application on the
company server (w2k3 server), everything worked still fine exept writing back
into an xml file!
The file i want to write to is stored in a dir. in the inetpub folder.

I've been looking around on the internet for a long time now, but NOTHING
worked!
 - I gave full trust in the .NET configuration (and tried much more)
 - added the ASPNET user
 - checked the machine.config

I admitt the whole .net security stuff is verry new to me but i think i
tried all the standart stuff.

I'd be so glad if someone could help me out here!

I will also post the exception that is thrown:

System.UnauthorizedAccessException: Der Zugriff auf den Pfad
D:\Inetpub\ApplicationData\ArtistSite\askArtist.xml wurde verweigert. at
System.IO.__Error.WinIOError(Int32 errorCode, String str) at
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean
bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode,
FileAccess access, FileShare share) at System.Xml.XmlDocument.Save(String
filename) at VL_CMS.EditXML.MyDataGrid_Update(Object sender,
DataGridCommandEventArgs e)