Sometimes it can be quite handy to display the build date of an assembly in an 'About' window or similar. After reading a couple of threads on how it can be calculated from the build and revision numbers, below is a very simple function to produce the build date for the currently executing assembly.
This ONLY works if the assembly was built using VS.NET and the assembly version attribute is set to something like the below. The asterisk (*) is the important part, as if present, VS.NET generates both the build and revision numbers automatically.
<Assembly: AssemblyVersion("1.0.*")>
The code...
Private Function BuildDate() As Date
'Build dates start from 01/01/2000
Dim result As Date = #1/1/2000#
'Retrieve the version information from the assembly from which this code is being executed
Dim version As System.Version = System.Reflection.Assembly.GetExecutingAssembly.GetName.Version
'Add the number of days (build)
result.AddDays(version.Build)
'Add the number of seconds since midnight (revision) multiplied by 2
result.AddSeconds(version.Revision * 2)
'If we're currently in daylight saving time add an extra hour
If TimeZone.IsDaylightSavingTime(Now, TimeZone.CurrentTimeZone.GetDaylightChanges(Now.Year)) Then result.AddHours(1)
Return result
End Function
An alternative method is to simply read the last time the file was written, using something similar to:
Return
System.IO.File.GetLastWriteTime(System.Reflection.Assembly.GetExecutingAssembly.Location)