C# 修改+抓取+顯示 軟體版本資訊

C# 修改+抓取+顯示 軟體版本資訊

C# 修改+抓取+顯示 軟體版本資訊

資料來源: https://stackoverflow.com/questions/909555/how-can-i-get-the-assembly-file-version
 

//—

//AssemblyInfo.cs

[assembly: AssemblyVersion(“0.1.1.8”)]
[assembly: AssemblyFileVersion(“2017/12/25 09:39”)]

//—

 

//—

//UI

//讀取AssemblyInfo.cs內的版本資訊
        private static System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
        private static FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);

        private static Assembly assem = Assembly.GetEntryAssembly();
        private static AssemblyName assemName = assem.GetName();
        private static Version ver = assemName.Version;

        private static string version = ver.ToString().Replace(“.”, “”) + ” [” + fvi.FileVersion + “]”;
        private static string productVersion = “-V” + version;
//—

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *