Extension method for getting the creation time of an assembly

This commit is contained in:
Chris Cameron
2017-11-17 12:20:25 -05:00
parent 546cabf0b4
commit 772a87bab6
2 changed files with 21 additions and 1 deletions

View File

@@ -20,7 +20,7 @@ namespace ICD.Common.Utils.Extensions
public static string GetPath(this Assembly extends) public static string GetPath(this Assembly extends)
{ {
if (extends == null) if (extends == null)
throw new ArgumentNullException(); throw new ArgumentNullException("extends");
string path = extends string path = extends
#if SIMPLSHARP #if SIMPLSHARP
@@ -43,5 +43,19 @@ namespace ICD.Common.Utils.Extensions
return IcdFile.Exists(path) ? path : null; return IcdFile.Exists(path) ? path : null;
} }
/// <summary>
/// Gets the creation date of the given assembly.
/// </summary>
/// <param name="extends"></param>
/// <returns></returns>
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);
}
} }
} }

View File

@@ -77,5 +77,11 @@ namespace ICD.Common.Utils.IO
{ {
return new IcdFileStream(File.Open(path, mode)); return new IcdFileStream(File.Open(path, mode));
} }
[PublicAPI]
public static DateTime GetCreationTime(string path)
{
return File.GetCreationTime(path);
}
} }
} }