From 772a87bab6692cb1422c69c2bf2fd819fb38be5d Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Fri, 17 Nov 2017 12:20:25 -0500 Subject: [PATCH] Extension method for getting the creation time of an assembly --- .../Extensions/AssemblyExtensions.cs | 16 +++++++++++++++- ICD.Common.Utils/IO/IcdFile.cs | 6 ++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ICD.Common.Utils/Extensions/AssemblyExtensions.cs b/ICD.Common.Utils/Extensions/AssemblyExtensions.cs index 6e260da..3a67c37 100644 --- a/ICD.Common.Utils/Extensions/AssemblyExtensions.cs +++ b/ICD.Common.Utils/Extensions/AssemblyExtensions.cs @@ -20,7 +20,7 @@ namespace ICD.Common.Utils.Extensions public static string GetPath(this Assembly extends) { if (extends == null) - throw new ArgumentNullException(); + throw new ArgumentNullException("extends"); string path = extends #if SIMPLSHARP @@ -43,5 +43,19 @@ namespace ICD.Common.Utils.Extensions return IcdFile.Exists(path) ? path : null; } + + /// + /// Gets the creation date of the given assembly. + /// + /// + /// + public static DateTime GetCreationTime(this Assembly extends) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + string path = extends.GetPath(); + return path == null ? DateTime.MinValue : IcdFile.GetCreationTime(path); + } } } diff --git a/ICD.Common.Utils/IO/IcdFile.cs b/ICD.Common.Utils/IO/IcdFile.cs index 32e35d5..7c8bdc0 100644 --- a/ICD.Common.Utils/IO/IcdFile.cs +++ b/ICD.Common.Utils/IO/IcdFile.cs @@ -77,5 +77,11 @@ namespace ICD.Common.Utils.IO { return new IcdFileStream(File.Open(path, mode)); } + + [PublicAPI] + public static DateTime GetCreationTime(string path) + { + return File.GetCreationTime(path); + } } }