-2

我正在做 C# Winform 应用程序。我有几个类库。每个图书馆也是项目。通常,我使用下面的代码来了解我的应用程序的构建日期。但是,我想知道每个类库的构建日期。任何帮助...

 DateTime buildDate = new 
        FileInfo(Assembly.GetExecutingAssembly().Location).LastWriteTime;
 MessageBox.Show(string.Format("Build Date : {0}", buildDate), "Version Info");
4

2 回答 2

1

更新 了这个呢?

System.IO.FileInfo fileInfo = new System.IO.FileInfo(Assembly.GetExecutingAssembly().Location);
DateTime lastModified = fileInfo.LastWriteTime;

或者你可以尝试这里的答案中解释的东西: ASP.NET - 在屏幕底部显示应用程序构建日期/信息

于 2013-08-15T08:15:24.913 回答
1

要获取进程中使用的所有程序集的列表 (AppDomain.CurrentDomain)[http://msdn.microsoft.com/en-us/library/system.appdomain.currentdomain.aspx],然后是AppDomain.GetAssemblies

使用该列表使用您的代码(new FileInfo(assembly.Location).LastWriteTime;,或者更好地使用该文章中的示例Version通过AssemblyName.Version获取:

  Console.WriteLine("The version of the currently executing assembly is: {0}",
        Assembly.GetExecutingAssembly().GetName().Version);

  Console.WriteLine("The version of mscorlib.dll is: {0}",
        typeof(String).Assembly.GetName().Version);
于 2013-08-15T08:44:00.620 回答