Wednesday, April 6, 2022

How to get the assembly file version in C#

Here is a sample code to get assembly file version in C#.
  1. System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
  2. System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
  3. string version = fvi.FileVersion;

Another approach is,
  1. var version = Application.ProductVersion;
This approach requires reference to below namespace.
  1. System.Windows.Forms

No comments:

Post a Comment