C# How to check if number is larger?

  • A+
Category:Languages

I'm working on a program for my class at school and I'm setting up AutoUpdates. Is there any way to make "else if (webClient.DownloadString("mylink").Contains("0.3.9"))" check the contains of the link to see if it is over or greater than 0.3.9??

    public Form1()     {         InitializeComponent();         WebClient webClient = new WebClient();           if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "//DesktopReborn//updates//Update-0.4.0.xml")) { }          else if (webClient.DownloadString("mylink").Contains("0.3.9"))         {             if (MessageBox.Show("An Update is Avaliable, Would you like to download it?", "DesktopReborn Updater", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)             {                 webClient.DownloadFile("myupdate", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "//DesktopReborn//DesktopReborn.exe");                  if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "//DesktopReborn//updates//Update-0.3.9.xml"))                 {                     File.Copy(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "//DesktopReborn//updates//Update-0.3.9.xml", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "//DesktopReborn//updates//Update-0.4.0.xml", true);                     File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "//DesktopReborn//updates//Update-0.3.9.xml");                 }             }         }     } 

 


.NET Framework comes with System.Version class that allows you to compare between version number.

var newVersion = new Version("0.3.9"); var oldVersion = new Version("0.3.8");  if(oldVersion < newVersion) {    //do something.. } 

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: