Sunday, June 30, 2013

My XML document will not save changes made to the document

Hello all,


I am building an application that will allow my user to change their password. Their password will be stored in an XML Document. Also, I plan on doing password reset based off of secret questions, stored in an XML document. My code steps-through without error, but the XML document remains unchanged.


In my properties for the XML file, I have tried to set "Copy to output" as "Copy Always", and "Copy if Newer", no luck.


My code for saving is as below:



XmlDocument XMLdoc = new XmlDocument();
string XMLfilename = "PasswordHoldDoc.xml";
XMLdoc.Load(XMLfilename);
XmlNode root = XMLdoc.DocumentElement;
String pwdNode = root.FirstChild.InnerText;
//XmlNode pwdNode = XMLdoc.SelectSingleNode("/directory/password");
if (pwdNode != null)
{
root.FirstChild.InnerText = passwordConfirmTextbox.Text;

XMLdoc.Save("PasswordHoldDoc.xml");
MessageBox.Show("done!");



-JG


No comments:

Post a Comment