February 5, 2016

How to get assembly information in C#

It is very easy to get assembly information in C#, you just need to use System.Reflection.Assembly.
You can see below code snippet for example I am fetching here assembly version info.

System.Reflection.Assembly assembly = Assembly.LoadFrom(Server.MapPath("~/bin/Sitecore.Kernel.dll"));
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);

string version = fvi.FileVersion;
string fileVersion = String.Empty;

fileVersion = version.Substring(0, 3);

That’s it.
Enjoy Learning

No comments:

Post a Comment