how to show publish version in a textbox?

前端 未结 5 2095
遥遥无期
遥遥无期 2020-12-14 15:29

At the moment I am manually updating the version field (textbox) in my application every time I publish it. I am wondering if there is a way to have my applicat

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-14 16:12

    If you get an error of ApplicationDeployment, then you can try this:

    For global version accessing through Program, declare inside Program class:

    private static Version version = new Version(Application.ProductVersion);
    
    public static Version Version
    {
        get
        {
            return version;
        }
    }
    

    Now you have Program.Version anywhere available in the program and you can use it to get version information like this:

    LabelVersion.Text = String.Format("Version {0}.{1}",
        Program.Version.Major.ToString(),
        Program.Version.Minor.ToString());
    

提交回复
热议问题