Skip to content

Commit d8dc1ab

Browse files
committed
Merge pull request #552 from baltie/path-too-long
Fixed path too long problem.
2 parents 719dbdd + ab49072 commit d8dc1ab

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed
Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
using System;
2-
using System.IO;
1+
using System.IO;
2+
using System.Linq;
33

44
public static class DirectoryDateFinder
55
{
66
public static long GetLastDirectoryWrite(string path)
77
{
8-
var lastHigh = DateTime.MinValue;
9-
foreach (var file in Directory.EnumerateDirectories(path, "*.*", SearchOption.AllDirectories))
10-
{
11-
var lastWriteTime = File.GetLastWriteTime(file);
12-
if (lastWriteTime > lastHigh)
13-
{
14-
lastHigh = lastWriteTime;
15-
}
16-
}
17-
return lastHigh.Ticks;
8+
return new DirectoryInfo(path)
9+
.GetDirectories("*.*", SearchOption.AllDirectories)
10+
.Select(d => d.LastWriteTimeUtc)
11+
.DefaultIfEmpty()
12+
.Max()
13+
.Ticks;
1814
}
1915
}

0 commit comments

Comments
 (0)