RSS

Assembly Creation Date

20 Feb

It might be sometimes the time when you need the creation date of the assembly or to name it more accurate, the build date. In order to get it you will need to retrieve the location on the hard drive where the assembly is located. Once found you have to retrieve the creation time of that file. This is achieved with following short piece of code.

Note:I do not care about handling errors in the following lines. It’s up to you whether you handle them or not. Also note that the following method is an extension method.

public static DateTime GetBuildDate(this Assembly assembly)
{
    if(assembly == null)
        throw new ArgumentNullException("assembly","should not be null.");
    returnĀ File.GetCreationTime(assembly.Location);
}
Advertisements
 
Leave a comment

Posted by on February 20, 2012 in C-Sharp

 

Tags:

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: