How to get the current product version in C#?

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

    In C# you need to use reflection and diagnostics

    Assembly assembly = Assembly.GetExecutingAssembly();
    FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
    string version = fileVersionInfo.ProductVersion;
    

提交回复
热议问题