I want to determine the file version of dll file in 'c#' when the path is specified. Suppose path = "\x\y\z.dll" .
How to find the file version of z.dll when path is given?
NOTE: I use Compact Framework 3.5 SP1
I want to determine the file version of dll file in 'c#' when the path is specified. Suppose path = "\x\y\z.dll" .
How to find the file version of z.dll when path is given?
NOTE: I use Compact Framework 3.5 SP1
// Get the file version for the notepad.
FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(Environment.SystemDirectory + "\\Notepad.exe");
// Print the file name and version number.
Console.WriteLine("File: " + myFileVersionInfo.FileDescription + '\n' +
"Version number: " + myFileVersionInfo.FileVersion);
From: http://msdn.microsoft.com/en-us/library/system.diagnostics.fileversioninfo.fileversion.aspx
So for you:
FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(@"\x\y\z.dll");
This works if the dll is .net or Win32. Reflection methods only work if the dll is .net.
Normal Framework
If it is a .NET DLL you can use Reflection.
If not, you can use System.Diagnostics:
Compact Framework
If you are using .NET Compact Framework you don't have access to FileVersionInfo
You can check this stackoverflow question. In the unique answer you have a link to a blog with code that fixes your problem.