468,119 Members | 1,983 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,119 developers. It's quick & easy.

Howto determine the Modified date of your executable?

Hello,

I know about the FileInfo.LastWriteTime() function. However, this is not
always returning the modified date of the executable that I want: when you
copy the executable to another directory the FileInfo.LastWriteTime()
function returns the copy-time.

I can see in my explorer that there is another modified time, the time when
I compiled the executable. My explorer (explorer2, that is, Zabkat's
dual-pane explorer) shows this timestamp also in the directory to which I
copied the executable, in the 'Modifed' column. So, there must be a field
somewhere that retains the original Modifed date. Does anyone know how to
get that?

What I really want is to have an 'About...' form in my application that
shows the last-build date. So, maybe there's another approach to that?

Regards,
Marcel Brekelmans
Sep 2 '06 #1
1 2742
I googled a nice way:

In your AssemblyInfo.cs file, leave out the Version and Build numbers:

[assembly: AssemblyVersion("1.1.*")]

After the compiler has build the application it has set Build to the number
of days since Jan 1, 2000 and Version to the number of seconds since
midnight (local time) divided by 2. From this information you can retrieve
the build timestamp:

Version v = new Version(Application.ProductVersion);

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

TimeZone localZone = TimeZone.CurrentTimeZone;

DateTime tt = localZone.IsDaylightSavingTime(t) ? t.AddHours(1) : t;

lblBuild.Text = tt.ToString();

v.Build - 1 : the number of days includes the current day. For today however
you must only count the time elapsed specified by Revision
The addHours(), of course, is specific to my timezone.
"Marcel Brekelmans" <ma****@marcel-art.comschreef in bericht
news:KO******************************@giganews.com ...
Hello,

I know about the FileInfo.LastWriteTime() function. However, this is not
always returning the modified date of the executable that I want: when you
copy the executable to another directory the FileInfo.LastWriteTime()
function returns the copy-time.

I can see in my explorer that there is another modified time, the time
when I compiled the executable. My explorer (explorer2, that is, Zabkat's
dual-pane explorer) shows this timestamp also in the directory to which I
copied the executable, in the 'Modifed' column. So, there must be a field
somewhere that retains the original Modifed date. Does anyone know how to
get that?

What I really want is to have an 'About...' form in my application that
shows the last-build date. So, maybe there's another approach to that?

Regards,
Marcel Brekelmans

Sep 2 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Logan | last post: by
11 posts views Thread by Dennis Marks | last post: by
28 posts views Thread by Tim Daneliuk | last post: by
7 posts views Thread by patrik.kahari | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.