Skip to content

Instantly share code, notes, and snippets.

@khmylov khmylov/gist:2469791
Created Apr 23, 2012

Embed
What would you like to do?
Get application version from assembly information.
public string GetAppVersion()
{
var assembly = Assembly.GetExecutingAssembly();
var name = assembly.FullName;
var nameComponents = name.Split(',');
if (nameComponents.Length >= 2)
{
var versionComponent = nameComponents[1];
var keyAndValue = versionComponent.Split('=');
if (keyAndValue.Length == 2)
{
var value = keyAndValue[1];
var versionBits = value.Split('.');
if (versionBits.Length >= 3)
{
return String.Format("{0}.{1}.{2}", versionBits[0], versionBits[1], versionBits[2]);
}
}
}
return String.Empty;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.