If for some reason you are not allowed to use the Version comparison method directly (for example, in a client-server scenario), another approach is to extract a long number from the version and then compare the numbers with each other. However, the number should have the following format: two digits for Major, Minor and Revision, and four for Build.
How to extract the version number:
var version = Assembly.GetExecutingAssembly().GetName().Version; long newVersion = version.Major * 1000000000L + version.Minor * 1000000L + version.Build * 1000L + version.Revision;
And then somewhere else you can simply compare:
if(newVersion > installedVersion) {
Note: The installed version is the previously extracted long number.
Fabian Bigler Oct 08 '18 at 10:10 2018-10-08 10:10
source share