FileVersionInfo.FileVersion返回的ProductVersion? [英] FileVersionInfo.FileVersion returns ProductVersion?

查看:410
本文介绍了FileVersionInfo.FileVersion返回的ProductVersion?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用C#来获取文件的版本:

I am trying to get the file version using C#:

string file = @"C:\somefile.dll";
Console.WriteLine(FileVersionInfo.GetVersionInfo(file).FileVersion);

对于大多数的文件,这是好的,但是,对于一些我收到的结果,比psented在Windows文件浏览器的那些$ P $不同。

For most files this is fine, however for some i receive results that are different than the ones presented in the Windows file explorer.

请参阅附带的图像。psented在windows文件版本$ P $是0.0.0.0,然而就是我开始使用文件版本属性为000.000.000.000

See the attached image: the file version presented in windows is "0.0.0.0", however the one i get using FileVersion property is "000.000.000.000".

我已经采用不同的版本的.net的尝试(2,3.5,4),得到相同的结果。

I've tried using different versions of the .NET (2, 3.5, 4) which give the same results.

其他人遇到这个问题?

谢谢 利奥尔

推荐答案

看来Windows资源管理器被剥离的版本部分的前导零。

It seems Windows Explorer are stripping leading 0s of the version parts.

尝试建立与文件版本001.001.001.001的组件,它会显示在浏览器1.1.1.1。但是,你的code将返回的实际值(001.001.001.001)。

Try creating an assembly with FileVersion 001.001.001.001, it will show as 1.1.1.1 in explorer. But your code would return the actual value (001.001.001.001).

编辑:

Explorer将返回001.001.001.001为的ProductVersion ,但只有当 AssemblyInformationalVersion 的没有设置,在这种情况下,它会返回,作为的ProductVersion。

Explorer will return 001.001.001.001 as ProductVersion, but only if AssemblyInformationalVersion isn't set, in which case it would return that as ProductVersion.

这篇关于FileVersionInfo.FileVersion返回的ProductVersion?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆