I’ve managed to get version checking working within my application that I’m porting to C# from VB .net.

This may not be the best method, but it appears to work quite well. I do have it checking against a file on a web server to get the latest available version, that involved streamreader and a webclient. But for this example I simply hard coded the updversion as a string.

Feel free to use this code and adapt it to your requirements, but if you post it elsewhere please give credit.

you can compile this in a console simply by issuing csc versioning.cs (assuming you save the file as versioning.cs and are running Visual Studio) or mcs versioning.cs (if you are using Mono) and then run it in a console.

I hope you find this useful.

[code lang=”csharp”]// Example version checking
// by Kimberly Jansen – http://kimmynz.com
// There are probably better ways to do this, and if you know of it please
// let me know
using System;
using System.Reflection;
using System.Text;

class versioning
// Get the version of the application from the assembly information
// normally this would read the Assembly information from the project,
// This simply returns as the version however.
static string AssemblyVersion
return Assembly.GetExecutingAssembly().GetName().Version.ToString();

public static void Main()
// I usually populate the updversion string by reading in a file from a webserver
// but for this example I’ll just hard code it.
// Try setting the updversion to
const string updversion = "";
// Define the different version numbers
Version curversion = new Version(AssemblyVersion);
Version newversion = new Version(updversion);

// Outputs the running version and update version information to the console.
Console.WriteLine("You are running version: {0}", curversion);
Console.WriteLine("The latest version available is {0}", updversion);

// compare the current version with the new version an act accordingly.
if (curversion >= newversion)
Console.WriteLine("You already have the latest version installed");
else if (curversion < newversion)
Console.WriteLine("A New version is available, You have {0}, please update to {1}", curversion, newversion);