如何从文件路径中获取 .exe 文件版本号 [英] How to get .exe file version number from file path

查看:34
本文介绍了如何从文件路径中获取 .exe 文件版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 .Net 3.5/4.0 和 C# 代码.

I am using .Net 3.5/4.0 with code in C#.

我正在尝试获取 C: 驱动器上的 exe 文件的版本号.

I am trying to get a version number of an exe file on my C: drive.

例如路径是:c:Programdemo.exe.如果 demo.exe 的版本号是 1.0.

For example path is: c:Programdemo.exe. If the version number of demo.exe is 1.0.

如何使用此路径获取版本号?.

How can i use this path to grab version number?.

推荐答案

您可以使用 FileVersionInfo.FileVersion 从路径中获取.

You can use FileVersionInfo.FileVersion to fetch this from a path.

var versionInfo = FileVersionInfo.GetVersionInfo(pathToExe);
string version = versionInfo.FileVersion; // Will typically return "1.0.0.0" in your case

这篇关于如何从文件路径中获取 .exe 文件版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆