문제

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)"
도움이 되었습니까?

해결책

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top