Skip to content

Commit b15cb63

Browse files
committed
Check for directory existence before attempting access.
Stops exception from being thrown and tripping breakpoints when debugging application code.
1 parent ab9fc9f commit b15cb63

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/Serilog.Sinks.File/Sinks/File/RollingFileSink.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,11 @@ void OpenFile(DateTime now, int? minSequence = null)
115115
_nextCheckpoint = _roller.GetNextCheckpoint(now) ?? now.AddMinutes(30);
116116

117117
var existingFiles = Enumerable.Empty<string>();
118-
try
118+
if (Directory.Exists(_roller.LogFileDirectory))
119119
{
120120
existingFiles = Directory.GetFiles(_roller.LogFileDirectory, _roller.DirectorySearchPattern)
121121
.Select(Path.GetFileName);
122122
}
123-
catch (DirectoryNotFoundException) { }
124123

125124
var latestForThisCheckpoint = _roller
126125
.SelectMatches(existingFiles)

0 commit comments

Comments
 (0)