【问题标题】:product version number产品版本号
【发布时间】:2010-10-23 05:01:15
【问题描述】:

我想检索 exe 的产品版本号。 如果可能的话,我需要一些可以从命令行运行的东西。

还有适用于 unix 的实用程序吗?我在 mac 和 pc 上都需要这个。

提前致谢。

高尔

【问题讨论】:

    标签: .net version


    【解决方案1】:

    System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

    using System.Diagnostics;
    ...
    
    public void GetFileVersion()
    {
    // Get the file version for the notepad.
    FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(@"C:\A.exe");
    
    // Print the file name and version number.
    String text = "File: " + myFileVersionInfo.FileDescription + '\n' +
    "Version number: " + myFileVersionInfo.FileVersion;
    Console.WriteLine(text);
    }
    

    或者通过读取 EXE 的 PE 标头可能是最好的选择:

    http://msdn.microsoft.com/en-us/library/ms809762

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多