473,383 Members | 1,822 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,383 software developers and data experts.

include build time in exe file

Hi,

I would like to include the build time in my application.
It's for my ? / About ... menu. It's annoying to change the label.Text
property for every release.

Is it possible to do so?

Thanks,
Sitar.

Nov 17 '05 #1
12 9099
You may get it from executing assembly:

System.Reflection.Assembly.GetÂ*ExecutingAssembly( ).GetName().Â*Version

Also make sure that AssemblyInfo.cs contains the following string:

[assembly: AssemblyVersion("1.0.*")]
Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Sitar wrote:
Hi,

I would like to include the build time in my application.
It's for my ? / About ... menu. It's annoying to change the label.Text
property for every release.

Is it possible to do so?

Thanks,
Sitar.

Nov 17 '05 #2
Ouch, I meant you may get an assembly version instead of build time.

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Sergey Bogdanov wrote:
You may get it from executing assembly:

System.Reflection.Assembly.GetÂ*ExecutingAssembly( ).GetName().Â*Version

Also make sure that AssemblyInfo.cs contains the following string:

[assembly: AssemblyVersion("1.0.*")]
Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Sitar wrote:
Hi,

I would like to include the build time in my application.
It's for my ? / About ... menu. It's annoying to change the
label.Text property for every release.

Is it possible to do so?

Thanks,
Sitar.

Nov 17 '05 #3
Hi Sitar

This might help
System.IO.File.GetCreationTime(Assembly.GetExecuti ngAssembly().Location)
"Sitar" <Si***@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
Hi,

I would like to include the build time in my application.
It's for my ? / About ... menu. It's annoying to change the label.Text
property for every release.

Is it possible to do so?

Thanks,
Sitar.

Nov 17 '05 #4

I used that one already so developpers can trace the version.
But the client specifically wants the build date and having to change the
date manually is not "damn I forgot"-free once the release is shipped already
:)

Thanks,
Sitar
__
"Sergey Bogdanov" wrote:
Ouch, I meant you may get an assembly version instead of build time.

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Sergey Bogdanov wrote:
You may get it from executing assembly:

System.Reflection.Assembly.GetÂ*ExecutingAssembly( ).GetName().Â*Version

Also make sure that AssemblyInfo.cs contains the following string:

[assembly: AssemblyVersion("1.0.*")]
Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Sitar wrote:
Hi,

I would like to include the build time in my application.
It's for my ? / About ... menu. It's annoying to change the
label.Text property for every release.

Is it possible to do so?

Thanks,
Sitar.

Nov 17 '05 #5
Though ... I was close. To get build date (without time) try this:

Version version =
System.Reflection.Assembly.GetExecutingAssembly(). GetName().Version;
DateTime dt = new DateTime(2000, 1, 1);
label.Text = dt.AddDays(version.Build).ToString();
Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Sergey Bogdanov wrote:
Ouch, I meant you may get an assembly version instead of build time.

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Sergey Bogdanov wrote:
You may get it from executing assembly:

System.Reflection.Assembly.GetÂ*ExecutingAssembly( ).GetName().Â*Version

Also make sure that AssemblyInfo.cs contains the following string:

[assembly: AssemblyVersion("1.0.*")]
Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Sitar wrote:
Hi,

I would like to include the build time in my application.
It's for my ? / About ... menu. It's annoying to change the
label.Text property for every release.

Is it possible to do so?

Thanks,
Sitar.

Nov 17 '05 #6
"Sitar" <Si***@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
Hi,

I would like to include the build time in my application.
It's for my ? / About ... menu. It's annoying to change the label.Text
property for every release.

Is it possible to do so?


There is a "magic" way. The actual date/time information of the last build
can be extracted from the version#. If you set the assemly version to
[assembly: AssemblyVersion("1.0.*")], which I think is the default. See the
code snippet below:

private void VersionInfo_Click(object sender, System.EventArgs e)
{
// user selected "VersionInfo" item
FileVersionInfo myFileVersionInfo =
FileVersionInfo.GetVersionInfo(Application.Executa blePath);
// Print the file name and version number.
string str = "Version " + myFileVersionInfo.Comments;
int nBuild = myFileVersionInfo.FileBuildPart;
int nPrivate = myFileVersionInfo.FilePrivatePart;
DateTime dt = new DateTime(2000,1,1);
dt = dt.AddDays(nBuild);
dt = dt.AddSeconds(nPrivate * 2);
str += " Built " + dt.ToShortDateString() + " @ " +
dt.ToShortTimeString();
this.ctlBuild.Text = str;
}
Nov 17 '05 #7

It all works. Thanks everyone.

Cheers,
Sitar.

Nov 17 '05 #8

But why specifically 2001-01-01 ?

Thanks,
Sitar.

Nov 17 '05 #9

Oops, typo. I meant why 2000-01-01?
And not DateTime.MinValue for instance?

Nov 17 '05 #10
That solution won't work on the Compact Framework since it is lacking the
System.Diagnostics.FileVersionInfo class (although I wrote a subset of it
for the SDF) - www.opennetcf.org/sdf/

Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

"Dan Baker" <dbmail> wrote in message
news:%2******************@TK2MSFTNGP15.phx.gbl...
"Sitar" <Si***@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
Hi,

I would like to include the build time in my application.
It's for my ? / About ... menu. It's annoying to change the label.Text
property for every release.

Is it possible to do so?


There is a "magic" way. The actual date/time information of the last
build can be extracted from the version#. If you set the assemly version
to [assembly: AssemblyVersion("1.0.*")], which I think is the default.
See the code snippet below:

private void VersionInfo_Click(object sender, System.EventArgs e)
{
// user selected "VersionInfo" item
FileVersionInfo myFileVersionInfo =
FileVersionInfo.GetVersionInfo(Application.Executa blePath);
// Print the file name and version number.
string str = "Version " + myFileVersionInfo.Comments;
int nBuild = myFileVersionInfo.FileBuildPart;
int nPrivate = myFileVersionInfo.FilePrivatePart;
DateTime dt = new DateTime(2000,1,1);
dt = dt.AddDays(nBuild);
dt = dt.AddSeconds(nPrivate * 2);
str += " Built " + dt.ToShortDateString() + " @ " +
dt.ToShortTimeString();
this.ctlBuild.Text = str;
}

Nov 17 '05 #11

I used Sergey's code in one line:
this.lblInfoVersion.Text+="\r\nBuilt "+new DateTime(2000, 1,
1).AddDays(System.Reflection.Assembly.GetExecuting Assembly().GetName().Version.Build).ToShortDateStr ing();

It works both on Desktop and CF.

Cheers,
Sitar.

Nov 17 '05 #12
Because the build number is the number of days since January 1st 2000. If
memory serves me right the revision is the number of seconds since midnight
divided by two.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/
"Sitar" <Si***@discussions.microsoft.com> wrote in message
news:BB**********************************@microsof t.com...

Oops, typo. I meant why 2000-01-01?
And not DateTime.MinValue for instance?


Nov 17 '05 #13

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

Similar topics

6
by: alan | last post by:
Dear all, I have written my own function by C. And my development platform is W2k with VC6.0. Then I also defined a header file to extern declare this function. After that, I include this...
5
by: David Mathog | last post by:
One thing that can make porting C code from one platform to another miserable is #include. In particular, the need to either place the path to an included file within the #include statement or to...
1
by: Alex VanderWoude | last post by:
I am trying to <include> some text into an XML documentation topic, but that text is stored in a file that is in a different directory than the "current" XML file. Using a relative path does not...
4
by: FrzzMan | last post by:
The subject may sound a lil dumb :D But my problem is: When my app run, it'll check if a specific file existed or not, if existed it's OK, if not it will create default file. I want to...
2
by: Tommy Vercetti | last post by:
I'm new to Managed C++ development, and I can't seem to get started. Every time I try to include vcclr.h I get bizarre compilation errors. I've isolated this to a really simple case: In Visual...
4
by: Anders Eriksson | last post by:
Hello! I'm using VC++ 7.1 and MFC. In a header file that is located in a different directory that the main project I include a header file that is located in the main project directory. The...
9
by: chat | last post by:
Hi, every body. I have 3 files like this: -------------------------------------------------------- file name : header.h #ifndef TEST_H #define TEST_H int a=1; double b=0.5;
18
by: gutmant | last post by:
Say you have a file, a.h with an include guard. If you include it twice and look at the preprocessed output, you see there's no sign for the second inclusion. However, if you include it twice -...
1
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
1)i have a page that has includes like : <!--#INCLUDE FILE=FuncInc.asp--> <!--#INCLUDE FILE=VBEncodeInc.asp--> i know how to translate the code it self to vb.net, but how should i build the...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.