-
October 28th, 2010, 10:03 AM
#1
Most recent compilation date and time
Dear code gurus,
I remember that in C++ there were __DATE__ and __TIME__ macros using which I could write the most recent compilation date and time and output it in "About" box.
Is there something like this in C# that I could readily use?
Thank you for your help!
-
October 28th, 2010, 11:42 AM
#2
Re: Most recent compilation date and time
I just used a function that reads the system clock. Use the command DateTime. Here is what I used to get the year. There are many other parameter you can from this, year, time, day of week + others. I don't know them all but DateTime is something that should work for you
DateTime localNow = DateTime.Now;
textBox2.Text = " " + Convert.ToString(localNow.Year) + "\n";
-
October 29th, 2010, 01:40 AM
#3
Re: Most recent compilation date and time
I don't know, I think it isn't. You can obtain the file from which the assembly was loaded and query its creation time.
Code:
Assembly a = Assembly.GetEntryAssembly();
FileInfo fi = new FileInfo(a.Location);
DateTime dt = fi.CreationTime;
Or you can add your own attribute to the assembly which would carry the compilation time (time of instantination the attribute).
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post.
-
November 2nd, 2010, 08:14 AM
#4
Re: Most recent compilation date and time
Check this out:
http://bytes.com/topic/c-sharp/answe...mpilation-date
You could run a program as a pre-build step which modifies the AssemblyInfo.cs file to contain the current data/time as a string.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|