如何获取可执行文件的版本? [英] How to Get Version of an Executable file?
本文介绍了如何获取可执行文件的版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
救世主!我正在编写一个vb.net程序来更新我的应用程序的自述文件.我想从其他已编译的应用程序中提取版本号.我想从可执行文件中读取版本号,而不是从其未编译资源中读取.
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.
如何在vb.net中做到这一点而无需使用诸如reshacker之类的外部工具?
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.)
推荐答案
您可以使用以下函数来做到这一点:
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
用法:
Debug.WriteLine(GetFileVersionInfo("C:\foo\bar\myapp.exe").ToString)
输出:
4.2.9.281
这篇关于如何获取可执行文件的版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文