如何动态获取程序的版本? [英] How to get the version of the program dynamically?
本文介绍了如何动态获取程序的版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道将程序添加到表单名称的程序版本。
我试过的内容:
更改此字符串的每个新版本:
I want to know the version of the program to add it to the form's name.
What I have tried:
Changing every new version this string:
string version="4.8".
并在任何地方使用此字符串
And use this string everywhere
推荐答案
对于任何类型的应用程序:
For any type of app:
Assembly.GetExecutingAssembly().GetName().Version
对于WinForm应用程序:
For a WinForm app:
Application.ProductVersion
使用 GetExecutingAssembly
获取程序集引用并不总是一个选项。对于需要引用底层程序集或程序集版本的项目,这是一个有用的静态助手类:
Using GetExecutingAssembly
for an assembly reference is not always an option. This a useful static helper class for projects where you need to reference the underlying assembly or assembly version:
public static class CoreAssembly
{
public static readonly Assembly Reference = typeof(CoreAssembly).Assembly;
public static readonly Version Version = Reference.GetName().Version;
}
不确定要实现的目标,但可以查看: c# - 如何获得汇编文件版本 - Stack Overflow [ ^ ]
更多细节见: AssemblyName .Version Property(System.Reflection) [ ^ ]
Not sure what you want to achieve, but you can check this: c# - How can I get the assembly file version - Stack Overflow[^]
More details at: AssemblyName.Version Property (System.Reflection)[^]
这篇关于如何动态获取程序的版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文