C# 获取文件版本

var versionInfo = FileVersionInfo.GetVersionInfo(filePath);

String productVersion = versionInfo.ProductVersion;
String fileVersion = versionInfo.FileVersion;

其中

productionVersion/fileVersion为右键属性中的产品版本号及文件版本号。

在程序集属性中两者分别对应:

[assembly: AssemblyFileVersion("1.0.0.1")]
[assembly: AssemblyInformationalVersion("1.0.1.1")]

而程序集中常见的[assembly: AssemblyVersion("1.0.0.0")]属性则是程序集版本号,该号与要调用该程序集的程序集有关。

原文地址:https://www.cnblogs.com/hshuzhao/p/4185347.html