claudebl
claudebl

Reputation: 73

How to display the version number of an application in vb.net?

I'm trying to find out how I will be able to display in a label the version number of my application, not that of the assembly, here 1.0.0.0? But that of the application: 2.2.0.1 I am attaching a screenshot to you, acknowledging that I am not sure I did the right thing on the version number. Should I have left it as it was, i.e. also 1.0.0.0 Thanks in advance, Claude.

enter image description here

Upvotes: 1

Views: 5506

Answers (1)

Caius Jard
Caius Jard

Reputation: 74680

You solved it thus (extracted from your edit to the qustion; post answers as answers, do not post answers as question edits):

    Dim unused = FileVersionInfo.GetVersionInfo(Path.Combine(My.Application.Info.DirectoryPath, "Prenommer.exe"))
    Dim myFileVersionInfo As FileVersionInfo = FileVersionInfo.GetVersionInfo(My.Application.Info.DirectoryPath + "\Prenommer.exe")

    Label4.Text = myFileVersionInfo.FileVersion

I wanted to point out your code seems redundant and can be simplified:

    Dim myFileVersionInfo = FileVersionInfo.GetVersionInfo(Application.ExecutablePath)
    Label4.Text = myFileVersionInfo.FileVersion

Please give your controls better names than "Label4". To rename a control, change the text in the (Name) entry of the property grid

Upvotes: 1

Related Questions