Ahh...Tim...what's the purpose of your IsLaterThan() function?
Just to make sure that the file that is going to be copied over is later than the one that is there now. If it isn't a newer version, then don't copy it. This is a one way copy, not syncing.
Hi Tim.
I think what Glenn was getting at is, why write a function that is essentially a reinvention of the DateTime's overloaded > (is-greater-than) operator ?
Those who are new to OOP and C# often find themselves reinventing things that already exist, merely because they did not know they were there. So, when one is just starting out, they can probably avoid reinventing many things that already exist if they were to just spend some time becoming more familiar with some of the basic principles and concepts of an OOP language and C# in particular, like operators and operator overloading.
In a nutshell, operator overloading allows a class to supply the code that is used to perform comparisons when instances of the class appear on both sides of a langauge operator like >, ==, <, and so on (e.g., as in 'Today > Yesterday', where Today and Yesterday are both DateTimes).
In other words, all of that code in your IsLaterThan() method is functionally equivalent to this:
public bool IsLaterThan( DateTime thisDate, thatDate b )
{
return thisDate > thatDate;
}
And I think a little common sense allows us to realize that a DateTime is 'later than' another DateTime, if it is greater than the other DateTime.
The > operator overload for the DateTime class simply compares its internal double (which represents the date and time) to the internal double of the other DateTime operand.