如何确定精简框架3.5 DLL文件的文件版本 [英] How to determine file version of dll file in Compact Framework 3.5

查看:315
本文介绍了如何确定精简框架3.5 DLL文件的文件版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要确定'C#的dll文件的文件版本指定的路径时。
假设路径=\x\y\z.dll。

I want to determine the file version of dll file in 'c#' when the path is specified. Suppose path = "\x\y\z.dll" .

如何找到z.dll的文件版本给出的路径是什么时候?

请注意:我使用Compact Framework的3.5 SP1

NOTE: I use Compact Framework 3.5 SP1

推荐答案

普通框架

如果它是一个.NET的DLL,你可以使用反射

If it is a .NET DLL you can use Reflection.

using System.Reflection;

Assembly assembly = Assembly.LoadFrom("\x\y\z.dll");
Version ver = assembly.GetName().Version;

如果没有,你可以使用System.Diagnostics程序:

If not, you can use System.Diagnostics:

using System.Diagnostics;

static string GetDllVersion(string dllPath)
{
  FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(dllPath);
  return myFileVersionInfo.FileVersion;
}

// Sample invokation
string result = GetDllVersion(@"C:\Program Files (x86)\Google\Chrome\Application\20.0.1132.57\chrome.dll");
// result value **20.0.1132.57**



Compact Framework的

如果您正在使用的 .NET Compact Framework的你没有访问 FileVersionInfo

If you are using .NET Compact Framework you don't have access to FileVersionInfo

您可以检查此的计算器问题。在独特的答案你有一个链接与代码博客能解决你的问题。

You can check this stackoverflow question. In the unique answer you have a link to a blog with code that fixes your problem.

这篇关于如何确定精简框架3.5 DLL文件的文件版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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