Get Application Version

I use this small helper function to get the same text of my Version infor.

The Version should be set in the AssemblyInfo for .Net Framework and in the project properties for .Net

using System.Diagnostics;

namespace MyNamespace
{
    public static class Helpers
    {
        // NOTE: Application version text, updated date before release
        public static string GetApplicationVersion()
        {
            var assembly = System.Reflection.Assembly.GetExecutingAssembly();
            var fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
            string appVersion = $"MyApplication V{fvi.FileMajorPart}.{fvi.FileMinorPart}.{fvi.FileBuildPart} - 2025-03-10";
            return appVersion;
        }
    }
}


Posted

in

by

Tags: