473,096 Members | 1,419 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,096 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 22386
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...
2
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
1
by: jimatqsi | last post by:
So, I had this bright idea today that didn't quite work out. Or maybe it is working out but requires me to change a habit. I'm working on a form that will be a sub-form of another form. During...

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.