瀏覽代碼

Added GetFiles

Piotr Czajkowski 5 月之前
父節點
當前提交
e7d0ffebc9
共有 3 個文件被更改,包括 7 次插入2 次删除
  1. 4 1
      ProcessFiles/Interfaces/IDirectory.cs
  2. 2 0
      ProcessFiles/Models/DefaultDirectory.cs
  3. 1 1
      ProcessFiles/ProcessFiles.cs

+ 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)