2010-10-23 162 views
1

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

也有一个实用的UNIX?我在Mac和PC上都需要这个。

在此先感谢。 。

高尔

回答

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

相关问题