Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi folks I'm deploying a project using Clickonce and trying to get the date/time info for when I build the program in VS2010, and display this info when a client install the .exe, when I try to use
Dim buildDate As DateTime = New
VB
FileInfo(Assembly.GetExecutingAssembly().Location).LastWriteTime


this only gets me the time when the .exe is installed on the client's computer, not the build time(which is of course earlier than the installed time). Wondering whether there's a straightforward way to get a build date? Thx.

p.s.OriginalGriff i'm not quite savvy with .net and I'm coding in VB,so i'm just goin to overlook your post in C#

---------------
Do you guys think this
Dim buildDate as DateTime = new DateTime(2000,1,1).AddDays(
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Build )
will give the actual build date instead of Installed date??
Posted
Updated 20-Jul-12 10:48am
v2
Comments
lewax00 20-Jul-12 17:28pm    
Any reason you can't try it out? Build it, change the date on your computer, run it and see which date you get.
SandiegoSSD 20-Jul-12 21:02pm    
I changed my local time on computer to tomorrow(7/21) yet it still gives 7/20 when I build it, debug it on MY computer, whose local time is tomorrow. And this is before I even publish it.
lewax00 20-Jul-12 21:04pm    
Try a rebuild instead, if no code changed it won't be recompiled with just hitting build. But that sounds like its working to me.

Check this out:

http://www.codinghorror.com/blog/2005/04/determining-build-date-the-hard-way.html[^]

It's a good discussion of your problem and it gives a method of reading the timestamp created by the linker.

No idea if it works with the VS2010, but looking at the comments, it worked for somebody as recently as Feb 2010. It's worth a try.
 
Share this answer
 
VB
Dim v As System.Version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version


 Dim buildDate As DateTime = New DateTime(2000, 1, 1, 0, 0, 0).AddDays(v.Build). _
           AddSeconds(v.Revision * 2)


lblProgramVersion.Text = "Program built:  " & buildDate.ToLongDateString() & buildDate.ToLongTimeString()
 
Share this answer
 
VB
Dim lFileDateTime = System.IO.File.GetLastWriteTime(Replace(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase), "file:\", "") & "\YOUR_APPLICATION_FILENAME.exe")
        Dim lDateBuild As New Date(lFileDateTime.Ticks)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900