24 lines
698 B
C#
24 lines
698 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace PartSource.Automation.Extensions
|
|
{
|
|
public static class FileInfoExtensions
|
|
{
|
|
public static DateTime GetWhiTimestamp(this FileInfo fileInfo)
|
|
{
|
|
Match match = Regex.Match(fileInfo.Name, "[0-9]{8}");
|
|
|
|
return match.Success && DateTime.TryParseExact(match.Value, "MMddyyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime timestamp)
|
|
? timestamp
|
|
: DateTime.MinValue;
|
|
}
|
|
}
|
|
}
|