获取 .NET 程序集的日期 [英] Getting the date of a .NET assembly
问题描述
如何从当前的 .NET 程序集中检索创建日期?
How can I retrieve the Created date from the current .NET assembly?
我想添加一些非常简单的功能,让我的应用在主程序集的构建日期一周后停止工作.我已经编写了在给定日期后杀死我的应用程序的代码.我只需要以编程方式从程序集中检索创建日期.
I'd like to add some realy simple functionality where my app stops working one week after the build date of the main assembly. I already wrote the code that kills my app after a given date. I just need to programmatically retrieve the creation date from the assembly.
推荐答案
我不认为程序集本身包含它的创建日期.我怀疑你能得到的最接近的是程序集文件本身的创建日期:
I don't think the assembly itself contains it's creation date. I suspect the closest you can get is the creation date of the assembly file itself:
File.GetCreationTime(Assembly.GetExecutingAssembly().Location)
应该可以解决问题.
我认为 Jeff Atwood 的解决方案(在此线程中由手榴弹"编写)可能是现在更好的方法.
I think Jeff Atwood's solution, written up by "grenade" in this thread, is probably the better way to go now.
这篇关于获取 .NET 程序集的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!