diff --git a/Helpers/HelperEAFLog.cs b/Helpers/HelperEAFLog.cs index 52f6af2..ac30c2c 100644 --- a/Helpers/HelperEAFLog.cs +++ b/Helpers/HelperEAFLog.cs @@ -7,7 +7,8 @@ internal static partial class HelperEAFLog internal static bool DeleteFiles(AppSettings appSettings, ILogger logger) { - IEnumerable files = Directory.EnumerateFiles(appSettings.WatchDirectory, appSettings.EAFLogConfiguration.SearchPattern, SearchOption.AllDirectories); + string[] files = Directory.GetFiles(appSettings.WatchDirectory, appSettings.EAFLogConfiguration.SearchPattern, SearchOption.AllDirectories); + logger.LogInformation("After {MillisecondsDelay} with search pattern '{SearchPattern}' found {files}", appSettings.MillisecondsDelay, appSettings.EAFLogConfiguration.SearchPattern, files.Length); foreach (string file in files) { if (file.EndsWith(".dll")) @@ -19,7 +20,7 @@ internal static partial class HelperEAFLog try { File.Delete(file); } catch (Exception ex) - { logger.LogError(ex, "Inner loop error!"); } + { logger.LogInformation(ex, "Inner loop error!"); } } return true; } diff --git a/Worker.cs b/Worker.cs index 4faa553..750fcb2 100644 --- a/Worker.cs +++ b/Worker.cs @@ -1,5 +1,6 @@ using File_Watcher.Models; using Microsoft.Extensions.Hosting.WindowsServices; +using System.Data; namespace File_Watcher; @@ -41,6 +42,8 @@ public partial class Worker : BackgroundService private async Task Body(CancellationToken stoppingToken) { + if (!_IsWindowsService) + throw new EvaluateException("Set break point and skip!"); while (_IsWindowsService && !stoppingToken.IsCancellationRequested) { Body();