FileVersionInfo.FileVersion returns ProductVersion?

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

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

For most files, this is normal, but for some, I get results that are different from those presented in the Windows file explorer.

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

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

Has anyone else experienced this issue?

Thanks lior

enter image description here

0
source share
2 answers

Windows Explorer seems to drop the leading 0s version parts.

FileVersion 001.001.001.001, 1.1.1.1 . (001.001.001.001).

EDIT:

Explorer 001.001.001.001 ProductVersion, AssemblyInformationalVersion , ProductVersion.

+1

, WIN32 API ( ) , integer, .NET - integer.

FileVersionInfo, , -:

 this.productVersion = GetFileVersionString(memIntPtr, string.Format(CultureInfo.InvariantCulture, format, new object[] { codepage, "ProductVersion" }))

:

this.fileMajor = HIWORD(fixedFileInfo.dwFileVersionMS);
this.fileMinor = LOWORD(fixedFileInfo.dwFileVersionMS);
this.fileBuild = HIWORD(fixedFileInfo.dwFileVersionLS);
this.filePrivate = LOWORD(fixedFileInfo.dwFileVersionLS);
+1

All Articles