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.
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.
I don't know about native dlls but with managed dlls it works like this:
System.Reflection.Assembly.LoadFile(file).GetName().Version
EDIT: I think you can read the version info in C with GetFileVersionInfo()
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With