Scanner Fix (#2998)
This commit is contained in:
parent
6139b3fbdf
commit
11635c6696
6 changed files with 78 additions and 4 deletions
|
|
@ -745,12 +745,12 @@ public class DirectoryService : IDirectoryService
|
|||
/// <summary>
|
||||
/// Recursively scans a folder and returns the max last write time on any folders and files
|
||||
/// </summary>
|
||||
/// <remarks>If the folder is empty, this will return MaxValue for a DateTime</remarks>
|
||||
/// <remarks>If the folder is empty or non-existant, this will return MaxValue for a DateTime</remarks>
|
||||
/// <param name="folderPath"></param>
|
||||
/// <returns>Max Last Write Time</returns>
|
||||
public DateTime GetLastWriteTime(string folderPath)
|
||||
{
|
||||
if (!FileSystem.Directory.Exists(folderPath)) throw new IOException($"{folderPath} does not exist");
|
||||
if (!FileSystem.Directory.Exists(folderPath)) return DateTime.MaxValue;
|
||||
var fileEntries = FileSystem.Directory.GetFileSystemEntries(folderPath, "*.*", SearchOption.AllDirectories);
|
||||
if (fileEntries.Length == 0) return DateTime.MaxValue;
|
||||
return fileEntries.Max(path => FileSystem.File.GetLastWriteTime(path));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue