[ACCEPTED]-Compile date and time-reflection
Accepted answer
If you set the assembly version (usually 9 in AssemblyInfo.cs) to Major.Minor.*
(e.g. 1.0.*
), then you 8 can probably retrieve the build date at 7 runtime with something like this:
var version = Assembly.GetExecutingAssembly().GetName().Version;
DateTime buildDate = new DateTime(2000, 1, 1)
.AddDays(version.Build)
.AddSeconds(version.Revision*2);
When using 6 a *
for the third and fourth part of the 5 assembly version, then these two parts are 4 set automatically at compile time to the 3 following values:
- third part is the number of days since 2000-01-01
- fourth part is the number of seconds since midnight divided by two (although some MSDN pages say it is a random number)
Oh, and you have to take 2 care of daylight saving time yourself (e.g. add 1 one hour if it's daylight saving time).
You can get it by this way:
File.GetLastWriteTime(Assembly.GetExecutingAssembly().Location);
Returns DateTime
object.
0
What about:
new FileInfo(Assembly.GetExecutingAssembly().Location).LastWriteTime;
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.