I've written an update method for one of my programs and for the most part it works well, but there is a slight issue. The way I have it check for updates is to simply download an XML file from my server and check the major, minor, and revision numbers in the file against those of the application. So if my application version is 2.2.1 and the XML file says 2.2.2, then the program would know an update was available. Here is my code:
The problem is, it doesn't always work how it's supposed to. For example, if I have an application version 2.2.2 and the update file says 2.1.2, it will prompt me to update since the minor version number in the XML is smaller than te application's version.
My question: what would be a better way to check for this? I keep going back to thinking nested if statements, something like:
But something seems wron with that. Maybe it's just me though, does this look right to you guys, or is there a better way?
And for the record, I'm discarding the *actual* revision number in a standard Assembly Version, and substituting it with the Build number. I do this just because I think 4-digit versions are ugly. Personal preference.
Code:
if (updateMajor > major || updateMinor > minor || updateRevision > revision)
{
// Update stuff
}
My question: what would be a better way to check for this? I keep going back to thinking nested if statements, something like:
Code:
if (updateMajor >= major)
{
if (updateMinor >= minor)
{
if (updateRevision > revision)
{
// Update stuff here...
}
}
}
And for the record, I'm discarding the *actual* revision number in a standard Assembly Version, and substituting it with the Build number. I do this just because I think 4-digit versions are ugly. Personal preference.
Comment