bgmCoder bgmCoder - 6 months ago 17
Vb.net Question

How to Get Version of an Executable file?

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

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