Get DLL version programatically : C#

 using System;  
 using System.Diagnostics;  
 namespace KnowDllVersionByFilePath  
 {  
   class Program  
   {  
     static void Main(string[] args)  
     {  
       // Get the version of the DLL executing  
       // Assembly assembly = Assembly.LoadFrom("Microsoft.SharePoint.dll");  
       // Version ver = assembly.GetName().Version;  
       string fileV =  
         @"C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint\v4.0_16.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.dll";  
       string fileVersion = FileVersionInfo.GetVersionInfo(fileV).FileVersion;  
       string productVersion = FileVersionInfo.GetVersionInfo(fileV).ProductVersion;  
       Console.WriteLine("File Version = "+fileVersion);  
       Console.WriteLine("Product Version = " + productVersion);  
       Console.ReadKey();  
     }  
   }  
 }  

No comments:

Post a Comment