How to Get Version of an Executable file?

19,525

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
Share:
19,525
bgmCoder
Author by

bgmCoder

Salve! I am a Catholic Religious Brother, and all of my work is for the benefit of our chapels, faithful and priests. Besides my prayers and religious life, much of my practical work is involved in IT. I don't have any income, and have the vows of Poverty, Chastity and Obedience. Please visit our website if you are interested or curious! If you would like to contact me, please use my personal webform. Since you've read all this, if you want to know more, you can read this tidbit; and there is a photo here (that's me in the front).

Updated on June 08, 2022

Comments

  • bgmCoder
    bgmCoder almost 2 years

    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.)

  • bgmCoder
    bgmCoder almost 12 years
    Beautiful! This is a perfect answer - with code, output, etc! I spent about an hour of research trying to figure it out. However, it doesn't work on every program, it seems - at least, I know it does only work on files with the file version given in the resource, but I tried it on one particular file that does show it, but this wouldn't capture it. It seems to work on all my own programs though!