C# 獲取程序的三種版本

 public static class MainFileVersion
    { 
        public static Version AssemblyVersion
        {
            get { return ((Assembly.GetEntryAssembly()).GetName()).Version; }
        } 

        public static Version AssemblyFileVersion
        {
            get { return new Version(FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location).FileVersion); }
        }

        public static string AssemblyInformationalVersion
        {
            get { return FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location).ProductVersion; }
        }
    }



說明:
AssemblyVersion 程序集的版本例如 1.0.0.0 或 1.0.*
AssemblyFileVersion 程序文件版本在文件屬性中可以開到 例如 1.0.0.0
AssemblyInformationalVersion 程序文件產品版本,格式可以自己定義例如 V1.0 Alpha 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章