FileVersionInfo doesn't match Details tab in Explorer

主宰稳场 提交于 2019-12-01 21:06:28

问题


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.

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.

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)"

回答1:


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);


来源:https://stackoverflow.com/questions/8584197/fileversioninfo-doesnt-match-details-tab-in-explorer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!