Retrieving Assembly File Version
In AssemblyInfo, two distinct versions are defined:
While you can obtain the AssemblyVersion using Assembly.GetEntryAssembly().GetName().Version, the AssemblyFileVersion requires a different approach:
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion;
This code retrieves the assembly from the current executable, extracts the FileVersionInfo using its location, and ultimately extracts the FileVersion.
The above is the detailed content of How to Retrieve AssemblyFileVersion in C#?. For more information, please follow other related articles on the PHP Chinese website!