How to get the current product version in C#?

前端 未结 9 945
粉色の甜心
粉色の甜心 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:14

    There are three versions: assembly, file, and product. To get the product version:

    using System.Reflection;
    using System.Diagnostics;
    Assembly assembly = Assembly.GetExecutingAssembly();
    FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
    string version = fileVersionInfo.ProductVersion;
    

提交回复
热议问题