如何从文件路径获取.exe文件版本号 [英] How to get .exe file version number from file path
本文介绍了如何从文件路径获取.exe文件版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在我的c:驱动器上获取一个exe文件的版本号。例如路径是:
c:\Program\demo.exe,如果demo.exe的版本号是1.0,我该如何使用此路径抓取版本号。我使用的代码在C#.Net 3.5 / 4.0。
I am trying to get a version number of an exe file on my c: drive. For example path is: c:\Program\demo.exe , if the version number of demo.exe is 1.0 how can i use this path to grab version number. I am using .Net 3.5/4.0 with code in C#.
推荐答案
您可以使用FileVersionInfo.ProductVersion 从路径中提取此内容。
You can use FileVersionInfo.ProductVersion to fetch this from a path.
var versionInfo = FileVersionInfo.GetVersionInfo(pathToExe);
string version = versionInfo.ProductVersion; // Will typically return "1.0.0" in your case
这篇关于如何从文件路径获取.exe文件版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文