Read a non .NET DLL version from C#?

2019-03-17 14:21发布

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?

标签: c# dll
1条回答
劳资没心,怎么记你
2楼-- · 2019-03-17 14:36

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.

查看更多
登录 后发表回答