FileVersionInfo检索不正确的文件版本 [英] FileVersionInfo retrieving incorrect file version

查看:72
本文介绍了FileVersionInfo检索不正确的文件版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须通过C#检索详细信息选项卡下的值,例如,文件版本,.dll和.exe文件的产品版本。我正在为此使用以下代码。

I have to retrieve values under details tab e.g, File version, Product Version for .dll and .exe files through C#. I'm using the following code for this.

     FileVersionInfo myFile = FileVersionInfo.GetVersionInfo('Name of the file');
     //File Version
     string fileVersion = myFile.FileVersion;

此代码的问题是它为某些文件提供了错误的文件版本。这些文件的详细信息选项卡显示了不同的文件版本,并且代码检索了错误的值。我不确定为什么会这样。

The issue with this code is that it gives incorrect file version for some files. Details tab of these files shows different file version and code retrieves incorrect value. I'm not sure why this is happening.

请帮助。

推荐答案


预期版本(来自资源管理器)是10.0.0.35,我得到了! 10.0.000.0035

expected version(from Explorer) is 10.0.0.35 and i got 10.0.000.0035

这是相同的数字。文件版本号出现在本地资源两次中。在C ++程序中编辑版本资源时,您还可以看到一些内容。有人类可读的版本,没有格式限制。这就是您正在阅读的内容,请注意FileVersionInfo.FileVersion如何返回 string

That's the same number. The file version number appears in the native resource twice. Something you can also see when you edit a version resource in a C++ program. There's a human readable version with no restrictions on the format. That's what you are reading, note how FileVersionInfo.FileVersion returns a string.

有一个机器可读的版本,一个64位数字。每个部分有16位。这是资源管理器正在读取的内容。相应的属性是FileMajorPart,FileMinorPart,FileBuildPart和FilePrivatePart。请注意它们如何返回 int

And there's a machine readable version, a 64-bit number. With 16-bits each for the 4 parts. Which is what Explorer is reading. The corresponding properties are FileMajorPart, FileMinorPart, FileBuildPart and FilePrivatePart. Note how they return an int.

ProductVersion也具有此功能。

ProductVersion has this too.

这篇关于FileVersionInfo检索不正确的文件版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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