I want to update an XML file status When date is changing
if (DateTime.Parse(dsUpdate.Tables[0].Rows[0][1].ToString()) <= DateTime.Now)
{
XDocument xDoc = XDocument.Load(fi.FullName);
XElement upd = (from doc in xDoc.Descendants("sysInfo")
select doc).Single();
upd.Element("Status").Value = "Updated";
xDoc.Save(fi.FullName);
}
I am using this but somehow it doesn't work.The status of the file is not updated as the date changes. after loading the file it jumps to the catch block and nothing happen the status remains the same.
This is the XML file I am using:
<?xml version="1.0" encoding="utf-8"?>
<System>
<SysInfo>
<InstallDate>2/11/2015 2:26:21 PM</InstallDate>
<UpdateDate>2/12/2015 2:26:21 PM</UpdateDate>
<Status>Installed</Status>
</SysInfo>
</System>
No comments:
Post a Comment