CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2002
    Posts
    87

    Most recent compilation date and time

    Dear code gurus,

    I remember that in C++ there were __DATE__ and __TIME__ macros using which I could write the most recent compilation date and time and output it in "About" box.

    Is there something like this in C# that I could readily use?

    Thank you for your help!

  2. #2
    Join Date
    Oct 2010
    Location
    Houston, TX.
    Posts
    16

    Re: Most recent compilation date and time

    I just used a function that reads the system clock. Use the command DateTime. Here is what I used to get the year. There are many other parameter you can from this, year, time, day of week + others. I don't know them all but DateTime is something that should work for you

    DateTime localNow = DateTime.Now;
    textBox2.Text = " " + Convert.ToString(localNow.Year) + "\n";

  3. #3
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: Most recent compilation date and time

    I don't know, I think it isn't. You can obtain the file from which the assembly was loaded and query its creation time.
    Code:
          Assembly a = Assembly.GetEntryAssembly();
          FileInfo fi = new FileInfo(a.Location);
          DateTime dt = fi.CreationTime;
    Or you can add your own attribute to the assembly which would carry the compilation time (time of instantination the attribute).
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

  4. #4
    Join Date
    Apr 2004
    Location
    England, Europe
    Posts
    2,492

    Re: Most recent compilation date and time

    Check this out:

    http://bytes.com/topic/c-sharp/answe...mpilation-date

    You could run a program as a pre-build step which modifies the AssemblyInfo.cs file to contain the current data/time as a string.
    My hobby projects:
    www.rclsoftware.org.uk

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured