Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2005

Tip: Looking for answers? Try searching our database.

App version and build date?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JP - 06 May 2005 23:50 GMT
Ive set up my application to read the build version from the <assembly> key
inside my Web.config file using:

string myver = Assembly.GetExecutingAssembly().GetName().Version().ToString()

Is there a way to get the DATE of the build as well?
Signature

JP
.NET Software Developer

Marc Scheuner [MVP ADSI] - 07 May 2005 12:15 GMT
>Ive set up my application to read the build version from the <assembly> key
>inside my Web.config file using:
>string myver = Assembly.GetExecutingAssembly().GetName().Version().ToString()
>
>Is there a way to get the DATE of the build as well?

You'd have to load the file in question (DLL or EXE) into a FileInfo
and get the creation date off it.

FileInfo oMyFile = new
FileInfo(Assembly.GetExecutingAssembly().Location);

DateTime oBuildDate = oMyFile.CreationTime;
(or possibly oMyFile.CreationTimeUtc; )

HTH
Marc
Sergey Radkevich - 07 May 2005 21:19 GMT
> You'd have to load the file in question (DLL or EXE) into a FileInfo
> and get the creation date off it.

When I deployed another version of assembly several minutes later to the
same place,
the creation time of the file was not changed (only modification time).

So I have used modification time instead.
Michal Dabrowski - 09 May 2005 07:16 GMT
> Ive set up my application to read the build version from the <assembly> key
> inside my Web.config file using:
>
> string myver = Assembly.GetExecutingAssembly().GetName().Version().ToString()
>
> Is there a way to get the DATE of the build as well?

Here is sample code that retrieves build date from an assembly:

AssemblyName an = Assembly.GetEntryAssembly().GetName();
DateTime date = new DateTime(2000, 1, 1, 0, 0, 0);
date += TimeSpan.FromDays(an.Version.Build) +
TimeSpan.FromSeconds(an.Version.Revision * 2);

HTH

Michal Dabrowski
Marc Scheuner [MVP ADSI] - 10 May 2005 07:57 GMT
>Here is sample code that retrieves build date from an assembly:
>
>AssemblyName an = Assembly.GetEntryAssembly().GetName();
>DateTime date = new DateTime(2000, 1, 1, 0, 0, 0);
>date += TimeSpan.FromDays(an.Version.Build) +
>TimeSpan.FromSeconds(an.Version.Revision * 2);

That *ONLY* works *IF* you *DO NOT* change your assembly version
numbering !

By default, the "build" portion of your assembly will indeed reflect
the build date - but you can change that, if you wish to! And then,
your method here will fail miserably......

Marc
================================================================
Marc Scheuner                        May The Source Be With You!
Berne, Switzerland                      m.scheuner -at- inova.ch
Michal Dabrowski - 10 May 2005 10:19 GMT
>>Here is sample code that retrieves build date from an assembly:
>>
[quoted text clipped - 5 lines]
> That *ONLY* works *IF* you *DO NOT* change your assembly version
> numbering !

That's true, sorry, forgot to mention this. One has to leave the two
asterisks at the end of assembly version number for this method to work.

> By default, the "build" portion of your assembly will indeed reflect
> the build date - but you can change that, if you wish to! And then,
> your method here will fail miserably......

Yes, but looking at file creation date can also produce incorrect result
if the date is not preserved by all programs used between build and
deployment (although I think that most of them preserve it).

Best regards,
Michal Dabrowski

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.