How to get the current product version in C#?

前端 未结 9 937
粉色の甜心
粉色の甜心 2020-12-05 01:28

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

My code:

VersionNumber = System.Reflection.Assembly.GetExecutingAssembly().GetName         


        
9条回答
  •  天命终不由人
    2020-12-05 02:27

    Try this:

    var thisApp = Assembly.GetExecutingAssembly();
    AssemblyName name = new AssemblyName(thisApp.FullName);
    VersionNumber = "v. " + name.Version;
    

    Also, see this Microsoft Doc on the AssemblyName.Version property.

提交回复
热议问题