I am trying to read the file version from an exe file. ( - not product version.) I tested two sample codes.
var versionInfo = FileVersionInfo.GetVersionInfo(FilePath);
string Description = versionInfo .FileDescription;
string Company = versionInfo.CompanyName;
//1
string Fileversion1 = string.Format("{0}.{1}.{2}.{3}", versionInfo.FileMajorPart, versionInfo.FileMinorPart, versionInfo.FileBuildPart, versionInfo.FilePrivatePart);
//2
string Fileversion2 = versionInfo.FileVersion;
The result is shown below.
The following figure is an actual property of PowerShell.
MS applications such as notepad, cmd will get the same results as POwershell.
Check Putty with the same code:
I would like to know the file version in the properties of the application.
I have a history of upgrading from Windows8 to Windows10 through a free upgrade to Windows10. Can this behavior affect the outcome?
The documentation of property
FileVersion
is misleading. It makes you think it is a concatenation of major, minor, build and private numbers.Actually,
FileVersion
is extracted using a call to a system API function (VerQueryValue), which can returns something different.