how to show publish version in a textbox?
Try this:
using System.Deployment.Application;
public Version AssemblyVersion
{
get
{
return ApplicationDeployment.CurrentDeployment.CurrentVersion;
}
}
Then the caller to the getter property can de-reference the Major
, Minor
, Build
and Revision
properties, like this:
YourVersionTextBox.Text = AssemblyVersion.Major.ToString() + "."
+ AssemblyVersion.Minor.ToString() + "."
+ AssemblyVersion.Build.ToString() + "."
+ AssemblyVersion.Revision.ToString();
Don't forget to check if the application is networkdeployed otherwise it won't work in debug mode.
if (ApplicationDeployment.IsNetworkDeployed)
{
this.Text = string.Format("Your application name - v{0}",
ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString(4));
}