Home > Backend Development > C++ > How to Retrieve AssemblyFileVersion in C#?

How to Retrieve AssemblyFileVersion in C#?

Linda Hamilton
Release: 2024-12-27 08:08:17
Original
296 people have browsed it

How to Retrieve AssemblyFileVersion in C#?

Retrieving Assembly File Version

In AssemblyInfo, two distinct versions are defined:

  • AssemblyVersion: Represents the version of the attributed assembly.
  • AssemblyFileVersion: Specifies the version number used by a compiler for the Win32 file version resource. This number may differ from the assembly version.

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;
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template