如何获得在C#中当前产品版本? [英] How to get current Product Version in C#?

查看:94
本文介绍了如何获得在C#中当前产品版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何编程方式获得在C#中当前的产品版本?

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

我的代码:

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



我收到VERSIONNUMBER = 1.0.0.0。但目前的版本是1.0.0.12

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

推荐答案

我的回答了我的问题它只是给出参考System.Deployment。应用虽然它不会在Visual Studio中的研究与开发工作,但一旦应用程序部署,将工作。

I got the answer to my question its Just give the reference to System.Deployment.Application and though it wont work in developement of the visual studio but it will work once the application is deployed.

  //using System.Deployment.Application;
  //using System.Reflection;
   public string CurrentVersion
    {
        get
        {
            return ApplicationDeployment.IsNetworkDeployed
                   ? ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString()
                   : Assembly.GetExecutingAssembly().GetName().Version.ToString();
        }
    }      

这篇关于如何获得在C#中当前产品版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆