Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read a non .NET DLL version from C#?

Tags:

c#

dll

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?

like image 341
Jon Tackabury Avatar asked Dec 08 '08 15:12

Jon Tackabury


People also ask

How do I find a DLL version?

If you reference the dll in Visual Studio right click it (in ProjectName/References folder) and select "Properties" you have "Version" and "Runtime Version" there. In File Explorer when you right click the dll file and select properties there is a "File Version" and "Product Version" there.

What are DLL files in C?

In Windows, a dynamic-link library (DLL) is a kind of executable file that acts as a shared library of functions and resources. Dynamic linking is an operating system capability. It enables an executable to call functions or use resources stored in a separate file.


1 Answers

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.

like image 130
5 revs, 3 users 96% Avatar answered Sep 24 '22 23:09

5 revs, 3 users 96%