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.
Please help. Thanks in advance!!
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.
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 has this too.