tags:

views:

2570

answers:

1

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?

+22  A: 

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.

Andrew Flanagan
That's excellent - I was hoping there was a .NET-ish way to do this.
Jon Tackabury