开发者

C# Compile Time for Last Updated

I have a website and I want to include a "Last Compile Time: XX:XX:XX" in the footer of the website. Is there an automated way to alter the contents of an asp:开发者_开发技巧label at compile time?


You could use reflection to find the current assembly and get the last write time. Then you could either bind the Text property of your current label, or set it in the Page Load.

File.GetLastWriteTime(Assembly.GetExecutingAssembly().Location)

Or you could use UTC

File.GetLastWriteTimeUtc(Assembly.GetExecutingAssembly().Location)


We typically use the creation time of the assembly. It seems depending on the install the last write times may differ.

File.GetCreationTimeUtc(System.Reflection.Assembly.GetExecutingAssembly().Location)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜