Could someone please enlighten me as to how I can read the version of a natively compiled application?
Thanks!
Printable View
Could someone please enlighten me as to how I can read the version of a natively compiled application?
Thanks!
You could use the Environment class
e.g
Environment.Version.Build
Environment.Version.Major
Environment.Version.Revision
Environment.Version will give you the version number of the .NET Framework.
Are you asking how you can look at an executable in the file system and get it's version, as opposed to the version of your own app? If so then you would use FileVersionInfo.GetVersionInfo to get a FileVersionInfo object and then use the appropriate properties to get the information you need.
You can also get this information and more from the Assembly.
Code:using System.Reflection;
Assembly exeAssembly = Assembly.GetExecutingAssembly();
object[] attributes = exeAssembly.GetCustomAttributes( false );
foreach( object attribute in attributes )
{
...
else if( attribute is AssemblyFileVersionAttribute )
{
this.fileVersionTextLabel.Text = ((AssemblyFileVersionAttribute)attribute).Version;
}
...
}