FileVersionInfo与资源管理器中的“详细信息"选项卡不匹配 [英] FileVersionInfo doesn't match Details tab in Explorer

查看:157
本文介绍了FileVersionInfo与资源管理器中的“详细信息"选项卡不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用C# System.Diagnostics.FileVersionInfo 从以下列表中提取版本信息:文件.我这样做的目的是跟踪唯一的文件路径和版本组合.当文件更改时,我希望根据确切的更改来进行各种操作.

I'm attempting to use C# and System.Diagnostics.FileVersionInfo to extract the version information from a list of files. My purpose for doing this is to keep track of unique filepath and version combinations. When the files change I'd like various things to happen depending on what exactly changed.

我已经使用了 FileVersion ProductVersion 属性 FileVersionInfo 无济于事.两者报告的版本号与资源管理器中报告的版本号不同.

I've used both the FileVersion and ProductVersion properties of FileVersionInfo to no avail. Both report a different version number than what is reported in explorer.

使用explorer.exe的示例

An example using explorer.exe

Explorer Details tab reports: "6.1.7601.17567" (for both File and Product)
FVI.ProductVersion reports: "6.1.7600.16385"
FVI.FileVersion reports: "6.1.7600.16385 (win7_rtm.090713-1255)"

推荐答案

由于某些原因,ProductVersion属性与ProductMajorPart/MinorPart/BuildPart/PrivatePart不匹配.要获取实际版本,可以执行以下操作:

For some reason the ProductVersion property doesn't match the ProductMajorPart/MinorPart/BuildPart/PrivatePart... To get the actual version you can do this:

var fvi = FileVersionInfo.GetVersionInfo(path);
var productVersion = new Version(
                           fvi.ProductMajorPart,
                           fvi.ProductMinorPart,
                           fvi.ProductBuildPart,
                           fvi.ProductPrivatePart);
var fileVersion = new Version(
                           fvi.FileMajorPart,
                           fvi.FileMinorPart,
                           fvi.FileBuildPart,
                           fvi.FilePrivatePart);

这篇关于FileVersionInfo与资源管理器中的“详细信息"选项卡不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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