I use XmlTextWriter to build a simple xml and trying to write it to a network shared folder. Only a particular user, which is different from the user currently running the aps.net application, has the WRITE permission on the shared folder. I have the username and password of this privileged network user acount. But I don't know how do I pass the credentials to the XmlTextWriter object. Please advise. Appreciate your help.
Here is the code: - It throws 'Access to the path is denied'.
XmlTextWriter wt = new XmlTextWriter(@"\\myserver\MySharedFolder\\Test.xml", System.Text.Encoding.UTF8); wt.Formatting = Formatting.Indented; wt.WriteStartDocument(); wt.WriteStartElement("Titles"); wt.WriteStartElement("Title"); wt.WriteElementString("title", "JobA"); wt.WriteElementString("JobId","201"); wt.WriteElementString("Client", "ABC"); wt.WriteEndElement(); wt.WriteEndElement(); wt.Close();
To be more specific: I have a shared folder which allows only a particular user, say 'User A' to write files to it. But my asp.net application runs in a different user, say User B, which has no WRITE permission to the shared folder. Unfortunately I can't give write access to the user account User B in my specific scenario for some valid reason. Now the question is, how do I write a text file to the above mentioned shared folder from my asp.net application, if the password of user account User-A is given?
This post has been edited by JackOfAllTrades: 21 November 2012 - 04:09 AM
Reason for edit:: Added code tags