public string AssemblyFileVersion()
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false);
if (attributes.Length == 0)
{
return "";
}
else
{
return ((AssemblyFileVersionAttribute)attributes[0]).Version;
}
}
方法二
//得到指定程序集版本
private string GetAssemblyVersion(string name)
{
byte[] filedata = File.ReadAllBytes(name + ".exe");
return Assembly.Load(filedata).GetName().Version.ToString();
}