从C#读取非.NET DLL版本? [英] Read a non .NET DLL version from C#?

查看:149
本文介绍了从C#读取非.NET DLL版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件夹中有一些DLL(不是.NET程序集),我想读取它们中的文件信息。类似版本,名称等等。这是最好的方法?

解决方案

使用FileVersionInfo对象。以下是Microsoft网站上的一个示例,它从notepad.exe获取版本信息。

  public void GetFileVersion(){
//获取记事本的文件版本。
FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(%systemroot%\\Notepad.exe);

//打印文件名和版本号。
textBox1.Text =File:+ myFileVersionInfo.FileDescription +'\\\
'+
版本号:+ myFileVersionInfo.FileVersion;
}

here


I have a folder with some DLLs in it (not .NET assemblies) and I would like to read the file information in them. Things like the version, name... etc. What is the best way to approach this?

解决方案

Use the FileVersionInfo object. Here's an example from the Microsoft website that gets the version info from notepad.exe

public void GetFileVersion() {
    // Get the file version for the notepad.
    FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo("%systemroot%\\Notepad.exe");

    // Print the file name and version number.
    textBox1.Text = "File: " + myFileVersionInfo.FileDescription + '\n' +
       "Version number: " + myFileVersionInfo.FileVersion;
 }

Stolen from here.

这篇关于从C#读取非.NET DLL版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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