.NET中dll的版本号

rei*_*ein 25 .net c# versioning dll

鉴于以下内容:

string file = @"c:\somepath\somefile.dll";
Run Code Online (Sandbox Code Playgroud)

如何使用.NET查找该DLL的文件和产品版本号?

dll可以是本机的或托管的.

谢谢.

Lar*_*ens 38

是的,使用System.Diagnostics.FileVersionInfo.

string fileVersion = FileVersionInfo.GetVersionInfo(file).FileVersion;
string productVersion = FileVersionInfo.GetVersionInfo(file).ProductVersion;
Run Code Online (Sandbox Code Playgroud)

请注意,程序集的文件版本可能与其程序集版本不同.程序集版本是程序集标识的一部分.