-2

I'm doing C# Winform application. I have several class libraries. each library is also project. Usally, I used below code to know the build date of my application. However, I want to know build date for each class library. any help...

 DateTime buildDate = new 
        FileInfo(Assembly.GetExecutingAssembly().Location).LastWriteTime;
 MessageBox.Show(string.Format("Build Date : {0}", buildDate), "Version Info");
Rohit Vats
  • 79,502
  • 12
  • 161
  • 185
Changju.rhee
  • 463
  • 3
  • 11
  • 26
  • Consider searching for an answer yourself, before asking dublicate questions. http://stackoverflow.com/questions/2050396/getting-the-date-of-a-net-assembly – Drasive Aug 15 '13 at 08:16
  • 1
    Is you question: "How to get list of all assemblies?" Or maybe "How to get assembly where given class is defined"? - very unclear... – Alexei Levenkov Aug 15 '13 at 08:25
  • Or you are trying to reinvent "version" assembly attribute? – Alexei Levenkov Aug 15 '13 at 08:35
  • @Drasive, Thanks I read poseted article already. I didn't get information what I really want. – Changju.rhee Aug 15 '13 at 08:36
  • @AlexeiLevenkov, Thanks. I think " "How to get list of all assemblies?" is correct question. If I know all lists, then is it possible to know each build date ? right ? – Changju.rhee Aug 15 '13 at 08:38

2 Answers2

1

UPDATED What about this?

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

Or you could try something as explained in the answer here: ASP.NET - show application build date/info at the bottom of the screen

Community
  • 1
  • 1
Marcus
  • 8,230
  • 11
  • 61
  • 88
1

To get list of all assemblies in process use (AppDomain.CurrentDomain)[http://msdn.microsoft.com/en-us/library/system.appdomain.currentdomain.aspx] and then AppDomain.GetAssemblies.

With the list use your code (new FileInfo(assembly.Location).LastWriteTime; or better yet get Version via AssemblyName.Version by using sample from that article:

  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);
Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179