How to Get Version of an Executable file?

bgmCoder picture bgmCoder · Jun 28, 2012 · Viewed 19k times · Source

Salvete! I am writing a vb.net program to update the readme files for my applications. I want to extract the version number from other compiled applications. I want to read the version number from the executable, not from its uncompiled resources.

How can I do this in vb.net without using an external tool like reshacker?

(I found this link, but it is for another language.)

Answer

Matt Wilko picture Matt Wilko · Jun 28, 2012

You can use a function like this to do it:

Private Function GetFileVersionInfo(ByVal filename As String) As Version
    Return Version.Parse(FileVersionInfo.GetVersionInfo(filename).FileVersion)
End Function

Usage:

Debug.WriteLine(GetFileVersionInfo("C:\foo\bar\myapp.exe").ToString)

Output:

4.2.9.281