如何检查文件版本是否满足运行应用程序所需的要求 [英] How to check if the file version pass the requirement needed to run the application

查看:68
本文介绍了如何检查文件版本是否满足运行应用程序所需的要求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有关dll/exe文件版本的帮助.

我有一个API.dll和NET.exe,我想获取

档名:
版本:
语言:
公司:

然后,下一步是检查版本号是否通过了运行我的应用程序的要求. API.dll的必需版本号是1.21.1.1,NET.exe的必需版本是1.2.1.1.1.

该怎么做?
期待这个.
-谢谢-

I need a help regarding the version of dll/exe file.

I have a API.dll and NET.exe, I would like to get the

Filename:
Version:
Language:
Company:

Then the next thing to do is to check the version number if it pass the requirement to run my application. The required version number for API.dll is 1.21.1.1 and the required version for NET.exe is 1.20.1.1.

How to do this?
Looking forward to this.
-Thank You-

推荐答案

我已经在这里回答了这个问题:
检查文件是否兼容使用的系统 [ ^ ].

当您说我需要运行此工具所需的一切"时,您需要解释确切缺少的内容.我认为您已经有了此信息.也许您需要帮助您设计版本控制策略?

从某种意义上说,该语言不是应用程序的一部分.它是由当前的区域性和当前的线程区域性定义的.在任何文化中,您仍然可以使用任何语言.此外,相同的应用程序可以被多重培养.文化将在运行时被修改.

您可以对文化进行其他操作:在"AssemblyInfo.cs"中查看程序集属性:

I already answered this question here:
Checking file if it is compatible in the system used[^].

When you say "I need everything needed to run this tool", you need to explain what exactly is missing. I think you already have this information. Perhaps you need to help you to design the versioning strategy?

The language is not a part of application, in a way. It is defined by the current culture and current thread culture. With any culture you still can work with any language. Besides, the same application can be multi-cultured. The culture will be modified during run-time.

You can do a different thing about the culture: look at the assembly attributes in "AssemblyInfo.cs":

[assembly: AssemblyCulture("")]



这是一种中立的文化,但是您可以使用某些特定的文化,例如"FR-fr".您将可以通过您的工具对其进行检查(请参见下文).

公司也是一样.有这样的程序集属性:



This is a neutral culture, but you can use some particular culture, such as "FR-fr". You will be able to check it by your tool (see below).

Same thing is about company. There is such assembly attribute:

[assembly: AssemblyCompany("My Company Name")]



有关属性的其他示例,请参见"AssemblyInfo.cs"文件.您可以轻松创建自己的内容.
现在,现在要使用您的工具检查属性吗?请执行以下操作:



See your "AssemblyInfo.cs" file for other examples of attributes. You can easily create your own.
Now, now to check the attribute using your tool? Do the following:

using Assembly = System.Reflection.Assembly;
using AssemblyCompanyAttribute = System.Reflection.AssemblyCompanyAttribute;

//...

Assembly assembly = Assembly.LoadFrom(assemblyMainModuleFileName);
object[] attributes = assembly.GetCustom(typeof(AssemblyCompanyAttribute), false);
if (attributes != null && attributes.Length > 0) {
   AssemblyCompanyAttribute company = (AssemblyCompanyAttribute)attributes[0];
   string companyName = company.Company;
   //...
}



其他所有属性也一样.

—SA



Same thing about all other attributes.

—SA


然后您要看的内容
Then you what to look at FileVersionInfo[^] class.

FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo("NET.exe");

Console.WriteLine("File: " + myFileVersionInfo.FileDescription + " - " +
           "Version number: " + myFileVersionInfo.FileVersion);



通过Google找到了这个.



Found this one via Google.

// FileVersionInfo.Comments = AssemblyDescription
// FileVersionInfo.CompanyName = AssemblyCompany
// FileVersionInfo.FileDescription = AssemblyTitle
// FileVersionInfo.FileVersion = AssemblyFileVersion
// FileVersionInfo.LegalCopyright = AssemblyCopyright
// FileVersionInfo.LegalTrademarks = AssemblyTrademark
// FileVersionInfo.ProductName = AssemblyProduct
// FileVersionInfo.ProductVersion = AssemblyInformationalVersion


是的,你可以看看

http://msdn.microsoft.com/en-us/library/system.diagnostics. fileversioninfo.aspx [ ^ ]
yes you can look at

http://msdn.microsoft.com/en-us/library/system.diagnostics.fileversioninfo.aspx[^]


这篇关于如何检查文件版本是否满足运行应用程序所需的要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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