我想要检索exe的产品版本号。 如果可能的话,我需要一些可以从命令行工作的东西。
还有unix的实用工具吗?我在mac和pc上都需要这个。
提前致谢。
高尔
答案 0 :(得分: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头可能是最好的选择: