Browse Source

Added GetFiles

Piotr Czajkowski 5 months ago
parent
commit
e7d0ffebc9

+ 4 - 1
ProcessFiles/Interfaces/IDirectory.cs

@@ -1,7 +1,10 @@
-namespace ProcessFiles.Interfaces
+using System.IO;
+
+namespace ProcessFiles.Interfaces
 {
     public interface IDirectory
     {
         public bool Exists(string? path);
+        public string[] GetFiles(string path, string searchPattern, SearchOption searchOption);
     }
 }

+ 2 - 0
ProcessFiles/Models/DefaultDirectory.cs

@@ -6,5 +6,7 @@ namespace ProcessFiles.Models
     public class DefaultDirectory : IDirectory
     {
         public bool Exists(string? path) => Directory.Exists(path);
+        public string[] GetFiles(string path, string searchPattern, SearchOption searchOption)
+            => Directory.GetFiles(path, searchPattern, searchOption);
     }
 }

+ 1 - 1
ProcessFiles/ProcessFiles.cs

@@ -108,7 +108,7 @@ namespace ProcessFiles
             List<string> files = [];
             foreach (var extension in fileExtensions)
             {
-                files.AddRange(Directory.GetFiles(path, $"*.{extension}", searchOption));
+                files.AddRange(fileSystem.Directory.GetFiles(path, $"*.{extension}", searchOption));
             }
 
             if (files.Count == 0)