Version number of a dll in .NET

rein picture rein · Oct 8, 2009 · Viewed 21.2k times · Source

Given the following:

string file = @"c:\somepath\somefile.dll";

How can I find the file and product version numbers of that DLL using .NET?

The dll can be either native or managed.

Thanks.

Answer

Lars Truijens picture Lars Truijens · Oct 8, 2009

Yes, using System.Diagnostics.FileVersionInfo.

string fileVersion = FileVersionInfo.GetVersionInfo(file).FileVersion;
string productVersion = FileVersionInfo.GetVersionInfo(file).ProductVersion;

Be advised that the file version of an assembly could be different from its assembly version. The assembly version is part of the assembly's identity.