diff --git a/TVRename/Finders/LibraryFolderFileFinder.cs b/TVRename/Finders/LibraryFolderFileFinder.cs index eeed82563..e718c6812 100644 --- a/TVRename/Finders/LibraryFolderFileFinder.cs +++ b/TVRename/Finders/LibraryFolderFileFinder.cs @@ -46,11 +46,25 @@ protected override void Check(SetProgressDelegate prog, ICollection sh string baseFolder = me.Episode.Show.AutoAddFolderBase; LOGGER.Info($"Starting to look for {me.Filename} in the library: {baseFolder}"); + + List matchedFiles; - List matchedFiles = string.IsNullOrWhiteSpace(baseFolder) - ? new List() - : dfc.GetFilesIncludeSubDirs(baseFolder).Where(testFile => - ReviewFile(me, thisRound, testFile, settings, false, false, false)).ToList(); + if (string.IsNullOrWhiteSpace(baseFolder)) + { + matchedFiles = new List(); + } + else + { + FileInfo[] testFiles = dfc.GetFilesIncludeSubDirs(baseFolder); + if (testFiles is null) + { + matchedFiles = new List(); + } + else + { + matchedFiles = testFiles.Where(testFile => ReviewFile(me, thisRound, testFile, settings, false, false, false)).ToList(); + } + } foreach (KeyValuePair> seriesFolders in me.Episode.Show.AllFolderLocationsEpCheck( false)) @@ -61,7 +75,10 @@ protected override void Check(SetProgressDelegate prog, ICollection sh { if (string.IsNullOrWhiteSpace(folderName)) continue; LOGGER.Info($"Starting to look for {me.Filename} in the library folder: {folderName}"); - foreach (FileInfo testFile in dfc.GetFiles(folderName)) + FileInfo[] files = dfc.GetFiles(folderName); + if (files is null) continue; + + foreach (FileInfo testFile in files) { if (!ReviewFile(me, thisRound, testFile, settings, false, false, false)) continue;