You can use the following to get the File Version:
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo("filename.exe");
But how can you get the Assembly Version for a specific EXE file?
"Assembly File Version" is what shows when you right-click on a file and go to "properties" then the "details" tab. They are not the same. I've found that the assembly version is what's used when determining the user. config location in AppData.
AssemblyVersion: Specifies the version of the assembly being attributed. AssemblyFileVersion: Instructs a compiler to use a specific version number for the Win32 file version resource.
It's the version number given to file as in file system. It's displayed by Windows Explorer, and never used by . NET framework or runtime for referencing.
The assembly's version number, which, together with the assembly name and culture information, is part of the assembly's identity. This number is used by the runtime to enforce version policy and plays a key part in the type resolution process at run time.
From this blog article How to get assembly version without loading it:
AssemblyName.GetAssemblyName("filename.exe").Version
This avoids having to load the assembly in its entirity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With