473,387 Members | 1,664 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Make a C# program print its compilation date?

Is there a way to make a C# program print the date on which it was compiled?

Finding the file date of the executable is one way, but it's not foolproof.

Thanks!
Nov 15 '05 #1
8 22427
Not as far as I know. I had to solve it using the following elaborate
technic:

create a small program that reads the date and time using DateTime.Now and
serializes it into a small file. This program is exucute just before the
compilation of my main program. The generated serialized file is then
included in the application as an embedded resouce. Then in the program I
read this resource and deserialize to get the compilation date and time
back...

It's a lot of work, but ik works.
Hope this helps.

"Michael A. Covington" <Mi*****@CovingtonInnovations.com> wrote in message
news:OK*************@TK2MSFTNGP09.phx.gbl...
Is there a way to make a C# program print the date on which it was compiled?
Finding the file date of the executable is one way, but it's not foolproof.
Thanks!

Nov 15 '05 #2
Not as far as I know. I had to solve it using the following elaborate
technic:

create a small program that reads the date and time using DateTime.Now and
serializes it into a small file. This program is exucute just before the
compilation of my main program. The generated serialized file is then
included in the application as an embedded resouce. Then in the program I
read this resource and deserialize to get the compilation date and time
back...

It's a lot of work, but ik works.
Hope this helps.

"Michael A. Covington" <Mi*****@CovingtonInnovations.com> wrote in message
news:OK*************@TK2MSFTNGP09.phx.gbl...
Is there a way to make a C# program print the date on which it was compiled?
Finding the file date of the executable is one way, but it's not foolproof.
Thanks!

Nov 15 '05 #3
I saw somebody create a VS addin that sets the last two parts of the
assembly version to the date and time right before a build. I can't find it
now, but that would be another way (since you can pull up the assembly
version pretty easily in code). Plus it's kindof handy if you need to know
when you made a build just by looking at the version number of the .dll /
..exe

If I find it, I'll post a link here.

mike

"Jeroen Smits" <sm***@bc-br.com> wrote in message
news:u8*************@TK2MSFTNGP10.phx.gbl...
Not as far as I know. I had to solve it using the following elaborate
technic:

create a small program that reads the date and time using DateTime.Now and
serializes it into a small file. This program is exucute just before the
compilation of my main program. The generated serialized file is then
included in the application as an embedded resouce. Then in the program I
read this resource and deserialize to get the compilation date and time
back...

It's a lot of work, but ik works.
Hope this helps.

"Michael A. Covington" <Mi*****@CovingtonInnovations.com> wrote in message
news:OK*************@TK2MSFTNGP09.phx.gbl...
Is there a way to make a C# program print the date on which it was

compiled?

Finding the file date of the executable is one way, but it's not

foolproof.

Thanks!


Nov 15 '05 #4
I saw somebody create a VS addin that sets the last two parts of the
assembly version to the date and time right before a build. I can't find it
now, but that would be another way (since you can pull up the assembly
version pretty easily in code). Plus it's kindof handy if you need to know
when you made a build just by looking at the version number of the .dll /
..exe

If I find it, I'll post a link here.

mike

"Jeroen Smits" <sm***@bc-br.com> wrote in message
news:u8*************@TK2MSFTNGP10.phx.gbl...
Not as far as I know. I had to solve it using the following elaborate
technic:

create a small program that reads the date and time using DateTime.Now and
serializes it into a small file. This program is exucute just before the
compilation of my main program. The generated serialized file is then
included in the application as an embedded resouce. Then in the program I
read this resource and deserialize to get the compilation date and time
back...

It's a lot of work, but ik works.
Hope this helps.

"Michael A. Covington" <Mi*****@CovingtonInnovations.com> wrote in message
news:OK*************@TK2MSFTNGP09.phx.gbl...
Is there a way to make a C# program print the date on which it was

compiled?

Finding the file date of the executable is one way, but it's not

foolproof.

Thanks!


Nov 15 '05 #5
Try creating a FileInfo object by specifying the filepath of the dll.
Then you can view the last modified date.

Greetz,
-- Rob.

Michael Mayer wrote:
I saw somebody create a VS addin that sets the last two parts of the
assembly version to the date and time right before a build. I can't
find it now, but that would be another way (since you can pull up the
assembly version pretty easily in code). Plus it's kindof handy if
you need to know when you made a build just by looking at the version
number of the .dll / .exe

If I find it, I'll post a link here.

mike

"Jeroen Smits" <sm***@bc-br.com> wrote in message
news:u8*************@TK2MSFTNGP10.phx.gbl...
Not as far as I know. I had to solve it using the following elaborate
technic:

create a small program that reads the date and time using
DateTime.Now and serializes it into a small file. This program is
exucute just before the compilation of my main program. The
generated serialized file is then included in the application as an
embedded resouce. Then in the program I read this resource and
deserialize to get the compilation date and time back...

It's a lot of work, but ik works.
Hope this helps.

"Michael A. Covington" <Mi*****@CovingtonInnovations.com> wrote in
message news:OK*************@TK2MSFTNGP09.phx.gbl...
Is there a way to make a C# program print the date on which it was
compiled?

Finding the file date of the executable is one way, but it's not
foolproof.

Thanks!

Nov 15 '05 #6
Try creating a FileInfo object by specifying the filepath of the dll.
Then you can view the last modified date.

Greetz,
-- Rob.

Michael Mayer wrote:
I saw somebody create a VS addin that sets the last two parts of the
assembly version to the date and time right before a build. I can't
find it now, but that would be another way (since you can pull up the
assembly version pretty easily in code). Plus it's kindof handy if
you need to know when you made a build just by looking at the version
number of the .dll / .exe

If I find it, I'll post a link here.

mike

"Jeroen Smits" <sm***@bc-br.com> wrote in message
news:u8*************@TK2MSFTNGP10.phx.gbl...
Not as far as I know. I had to solve it using the following elaborate
technic:

create a small program that reads the date and time using
DateTime.Now and serializes it into a small file. This program is
exucute just before the compilation of my main program. The
generated serialized file is then included in the application as an
embedded resouce. Then in the program I read this resource and
deserialize to get the compilation date and time back...

It's a lot of work, but ik works.
Hope this helps.

"Michael A. Covington" <Mi*****@CovingtonInnovations.com> wrote in
message news:OK*************@TK2MSFTNGP09.phx.gbl...
Is there a way to make a C# program print the date on which it was
compiled?

Finding the file date of the executable is one way, but it's not
foolproof.

Thanks!

Nov 15 '05 #7
[assembly:AssemblyFileVersion("1.0.*")]

This will change into an attribute where the 3rd part is the number of days
since Jan 1, 2000, and the 4th part is the number of seconds since midnight
(local time) divided by 2. This attribute can be accessed from the Assembly
object, or as the FileVersion looking at the Win32 file version resource.

--
--Grant
This posting is provided "AS IS" with no warranties, and confers no rights.
"Michael Mayer" <mi**@mag37.com> wrote in message
news:OD**************@TK2MSFTNGP12.phx.gbl...
I saw somebody create a VS addin that sets the last two parts of the
assembly version to the date and time right before a build. I can't find it now, but that would be another way (since you can pull up the assembly
version pretty easily in code). Plus it's kindof handy if you need to know when you made a build just by looking at the version number of the .dll /
.exe

If I find it, I'll post a link here.

mike

"Jeroen Smits" <sm***@bc-br.com> wrote in message
news:u8*************@TK2MSFTNGP10.phx.gbl...
Not as far as I know. I had to solve it using the following elaborate
technic:

create a small program that reads the date and time using DateTime.Now and serializes it into a small file. This program is exucute just before the
compilation of my main program. The generated serialized file is then
included in the application as an embedded resouce. Then in the program I read this resource and deserialize to get the compilation date and time
back...

It's a lot of work, but ik works.
Hope this helps.

"Michael A. Covington" <Mi*****@CovingtonInnovations.com> wrote in message news:OK*************@TK2MSFTNGP09.phx.gbl...
Is there a way to make a C# program print the date on which it was

compiled?

Finding the file date of the executable is one way, but it's not

foolproof.

Thanks!



Nov 15 '05 #8

"Michael A. Covington" <Mi*****@CovingtonInnovations.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...

"Grant Richins [MS]" <gr*****@online.microsoft.com> wrote in message
news:uf**************@TK2MSFTNGP09.phx.gbl...
[assembly:AssemblyFileVersion("1.0.*")]

This will change into an attribute where the 3rd part is the number of

days
since Jan 1, 2000, and the 4th part is the number of seconds since

midnight
(local time) divided by 2. This attribute can be accessed from the

Assembly
object, or as the FileVersion looking at the Win32 file version

resource.

And for posterity, here is some working code. Thanks again!

private DateTime DateCompiled()

// Assumes that in AssemblyInfo.cs,
// the version is specified as 1.0.* or the like,
// with only 2 numbers specified;
// the next two are generated from the date.
// This routine decodes them.

{

System.Version v =
System.Reflection.Assembly.GetExecutingAssembly(). GetName().Version;

// v.Build is days since Jan. 1, 2000
// v.Revision*2 is seconds since local midnight
// (NEVER daylight saving time)

DateTime t = new DateTime(
v.Build * TimeSpan.TicksPerDay +
v.Revision * TimeSpan.TicksPerSecond * 2
).AddYears(1999);

return t;
}

Nov 15 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: The Eternal Squire | last post by:
PEP: 336 Title: Make None Callable Version: $Revision: 1.1 $ Last-Modified: $Date: 2004/11/03 16:58:30 $ Author: Andrew McClelland Status: Draft Type: Standards Track Content-Type: text/plain...
17
by: Igorati | last post by:
Hello all, I am still needing some help on this code, I have gone a bit further on it. Thank you for the help. I am trying to understand how to make the file searchable and how I am to make the...
0
by: Khalid Hussain | last post by:
hi Could someone please help me in following: I have VB 6 program which print reports, manually by pressing Print button, base upon Policy Statuses. I want to create a SQL job or any automatic...
2
by: Alex Vinokur | last post by:
------ foo.cpp ------ #include <iostream> using namespace std; int main() { #define FACTOR 10 for (unsigned long array_size = 1; ; array_size *= FACTOR) { int* p = new int;
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
7
by: Hal Vaughan | last post by:
I have a problem with port forwarding and I have been working on it for over 2 weeks with no luck. I have found C programs that almost work and Java programs that almost work, but nothing that...
8
by: Seeker | last post by:
Hello, In using Solaris Pro Compiler to compile Pro*C code. I am getting this error: make: Fatal error in reader: parser_proc_online.mk, line 26: Badly formed macro assignment Based on other...
21
by: mikhal80 | last post by:
Is it possible to write a program which would print out it's own source code, using C++?
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.