【问题标题】:How to display the version number of an application in vb.net?如何在 vb.net 中显示应用程序的版本号?
【发布时间】:2021-08-29 16:15:22
【问题描述】:

我正在尝试找出如何在标签中显示我的应用程序的版本号,而不是程序集的版本号,这里是 1.0.0.0? 但是应用程序的:2.2.0.1 我附上截图给你,承认我不确定我在版本号上做对了。我是否应该保持原样,即 1.0.0.0 在此先感谢克劳德。

【问题讨论】:

  • 你看过这门课吗? docs.microsoft.com/en-us/dotnet/api/…
  • 非常感谢史蒂夫,它可以工作,代码如下: Dim used = 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
  • 不要在 cmets 中发布大的代码块,尤其是未格式化的。您应该将您的解决方案作为答案发布,如果可以,请接受它。这样,每个人都知道问题有答案,这样他们就不会浪费时间打开它来寻求帮助,或者如果他们有同样的问题,他们就会知道打开它。

标签: vb.net numbers version .net-assembly


【解决方案1】:

您因此解决了它(从您对问题的编辑中提取;将答案作为答案发布,不要将答案作为问题编辑发布):

    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

我想指出您的代码似乎是多余的,可以简化:

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

请给您的控件起一个比“Label4”更好的名称。要重命名控件,请更改属性网格的 (Name) 条目中的文本

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-02
    • 2011-03-12
    • 2021-04-14
    • 1970-01-01
    • 2022-08-13
    • 1970-01-01
    相关资源
    最近更新 更多