从C#读取非.NET DLL版本?

从C#读取非.NET DLL版本?,c#,dll,C#,Dll,我有一个文件夹,其中包含一些DLL(不是.NET程序集),我想读取其中的文件信息。比如版本,名字。。。等等。解决这个问题的最佳方法是什么?使用FileVersionInfo对象。下面是一个来自Microsoft网站的示例,它从notepad.exe获取版本信息 public void GetFileVersion() { // Get the file version for the notepad. FileVersionInfo myFileVersionInfo = Fil

我有一个文件夹,其中包含一些DLL(不是.NET程序集),我想读取其中的文件信息。比如版本,名字。。。等等。解决这个问题的最佳方法是什么?

使用FileVersionInfo对象。下面是一个来自Microsoft网站的示例,它从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;
 }

从……偷来的。

我喜欢这个。适用于.NET和非.NET,不需要像其他更流行的.NET dll方法那样加载dll和反射。