How do I find the current time and date at compilation time in .net/C# application?

前端 未结 7 2149
孤城傲影
孤城傲影 2020-12-06 12:43

I want to include the current time and date in a .net application so I can include it in the start up log to show the user what version they have. Is it possible to retrieve

相关标签:
7条回答
  • 2020-12-06 13:18

    The only way I know of doing this is somewhat convoluted -

    You can have a pre-build event that runs a small application which generates the source code on the fly. An easy way to do this is to just overwrite a very small file that includes a class (or partial class) with the day/month/year hardcoded as a string constant.

    If you set this to run as a pre-build event, it will rewrite that file before every build.

    0 讨论(0)
提交回复
热议问题