Following is the sample code to compare versions for two file:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
static void Main(string[] args)
{
string strFileVersion1 = "1.0.2254.37578";
string strFileVersion2 = "1.0.2254.36884";
Version version1= new Version(strFileVersion1 );
Version version2 = new Version(strFileVersion2);
Console.WriteLine("File Version File 1 = " + strFileVersion1 + " File Version File 2 = " + strFileVersion2);
if (version1 > version2)
Console.WriteLine(strFileVersion1 + " is Newer then " + strFileVersion2);
else if (version1 < version2)
Console.WriteLine(strFileVersion1 + " is Older then " + strFileVersion2);
else
Console.WriteLine(strFileVersion1 + " is Equal to " + strFileVersion2);
Console.ReadLine();
}
OUTPUT:
File Version File 1 = 1.0.2254.37578 File Version File 2 = 1.0.2254.36884
1.0.2254.37578 is Newer then 1.0.2254.36884
File Version File 1 = 1.0.2254.37578 File Version File 2 = 1.0.2254.37578
1.0.2254.37578 is Equal to 1.0.2254.37578
File Version File 1 = 1.0.2154.37578 File Version File 2 = 1.0.2254.37578
1.0.2154.37578 is Older then 1.0.2254.37578
File Version File 1 = 3.0.2154.37578 File Version File 2 = 2.0.2254.37578
3.0.2154.37578 is Newer then 2.0.2254.37578
No comments:
Post a Comment