#region XML Reader (Load the XML file)
XmlDocument xdoc = new XmlDocument();
xdoc.Load(root + infoFolder + "setting.xml");
#endregion
#region Find out if its time to update installation files
var DateNow = DateTime.Now.ToString("yyyy-MM-dd");
var LastUpdate = xdoc.SelectSingleNode("/Settings/TimeUpdated").InnerText;
if (DateNow.CompareTo(LastUpdate) > 0)
{
MessageBox.Show ("Last time you updated you installation files was" + LastUpdate + ". Today its " + DateNow,("Its been 14days.(or more)"));
}
#endregion
This is what i came up with but, this only compare if 'Datenow' is higher then 'Lasteupdate' And i think CompareTo dont work with dates.
What i realy want to to compare Datenow and Lasteupdate and if its 14 days different, then show messagebox.
This is how i fixed the problem:
#region Find out if its time to update installation files
String LastUpdate = xdoc.SelectSingleNode("Knowhow/Settings/TimeUpdated").InnerText;
DateTime dt1 = DateTime.Now.AddDays(-14);
DateTime dt2 = DateTime.Parse(LastUpdate);
String DateToday = dt1.ToString("yyyy-MM-dd");
String DateINFO = dt2.ToString("yyyy-MM-dd");
if (dt1.Date > dt2.Date)
{
MessageBox.Show("Last time you updated you installation files was" + DateINFO + ". Its been Its been 14days.(or more)");
; }
else
{
MessageBox.Show("Dont need to update");
}
#endregion