product version number
I want to retrive the product version number of an exe. If possible I need some thing which can work from the command line.
开发者_高级运维Also is there an utility for unix as well? I need this on both mac and pc.
Thanks in advance.
Gaur
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
or
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);
}
or via reading the PE header of the EXE is probably the best bet:
http://msdn.microsoft.com/en-us/library/ms809762
精彩评论