从非执行可执行文件获取版本 [英] Get Version from Non Executing Executable File

查看:83
本文介绍了从非执行可执行文件获取版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何获取正在执行的应用程序或dll的版本.但是,我需要查找未执行的应用程序的属性.

I know how to get the version of an executing application or dll. However I need to find the properties of a non executing application.

我有一个小程序可以为我的主应用程序设置文件关联.使用此版本的旧版本的用户没有意义,因为该应用程序在启动时不接受参数.因此,当文件关联器启动时,它首先检查是否可以找到主应用程序.如果可以,那么我想检查属性而不执行它.如果该版本早于可以接受参数的版本,那么我想告诉我的用户更新而不是继续设置关联.

I have a small program to set a file association for my main application. There is no point in users of old versions running this since the application does not accept arguments on start up. So when the file associator starts it first checks to see if it can find the main app. If it can then I want to check the properties without executing it. If the version is earlier than one that can accept arguments then I want to tell my user to update rather than proceed to set the association.

我看过System.IO.FileInfo,但似乎没有包含任何版本信息.

I have looked at System.IO.FileInfo but that does not seem to include any Version information.

谢谢

推荐答案

您可以使用 FileVersionInfo.GetVersionInfo():

FileVersionInfo vi = FileVersionInfo.GetVersionInfo("myfile.dll");

string showVersion = vi.FileVersion;

string showVersion = vi.FileVersion;

//showVersion是实际版本号.

//showVersion is the actual version No.

这将返回文件/文档元数据,并且可以用于非托管DLL甚至Word文档.

This returns file/document metadata and can be used for unmanaged DLLs or even word documents as well.

您还可以使用Assembly:

You can also use Assembly:

Version v = Assembly.ReflectionOnlyLoadFrom("myfile.dll").GetName().Version;

其中将包含. .NET版本信息.

这篇关于从非执行可执行文件获取版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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