Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the current product version in C#?

Tags:

c#

windows

How can I programmatically get the current product version in C#?

My code:

VersionNumber = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); 

I am getting VersionNumber=1.0.0.0, but the current version is 1.0.0.12.

like image 866
Nivid Dholakia Avatar asked Jun 27 '11 13:06

Nivid Dholakia


People also ask

How do I put an application in ProductVersion?

You can set it explicitly by setting the assembly version within your assembly manifest. For more information, see Assembly Manifest. ProductVersion first looks to see if the assembly containing the main executable has the AssemblyInformationalVersion attribute on it.


1 Answers

There are three versions: assembly, file, and product. To get the product version:

using System.Reflection; using System.Diagnostics; Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); string version = fileVersionInfo.ProductVersion; 
like image 117
Tony Hou Avatar answered Sep 18 '22 12:09

Tony Hou