Question

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

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top