diff --git a/MainForm.cs b/MainForm.cs index 094d3e9..c0896b1 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -124,7 +124,7 @@ namespace RandomFileRunner if (File.Exists(item)) { - if (SmartFileSystem.IsFileAccessible(item)) + if (SmartDirectory.IsFileAccessible(item)) { foundFiles.Add(item); ThreadControl.SetText(label2, foundFiles.Count.ToString()); @@ -135,7 +135,7 @@ namespace RandomFileRunner if (Directory.Exists(item)) { - SmartFileSystem.GetFiles(item, textBox1.Text, SearchDirecory_OnFound); + SmartDirectory.GetFiles(item, textBox1.Text, SearchDirecory_OnFound); ThreadControl.SetText(label2, foundFiles.Count.ToString()); diff --git a/RandomFileRunner.csproj b/RandomFileRunner.csproj index aef1233..38b0b0c 100644 --- a/RandomFileRunner.csproj +++ b/RandomFileRunner.csproj @@ -21,20 +21,21 @@ - - - + + + + diff --git a/IO/SmartFileSystem.cs b/RyzStudio/IO/SmartDirectory.cs similarity index 96% rename from IO/SmartFileSystem.cs rename to RyzStudio/IO/SmartDirectory.cs index 6b75186..2921c02 100644 --- a/IO/SmartFileSystem.cs +++ b/RyzStudio/IO/SmartDirectory.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace RandomFileRunner.IO { - public class SmartFileSystem + public class SmartDirectory { public static List GetFiles(string path, string pattern) @@ -16,6 +16,8 @@ namespace RandomFileRunner.IO List fileList = new List(); List directoryList = new List(); + if (string.IsNullOrWhiteSpace(pattern)) pattern = "*"; + directoryList.Add(path); while (true) @@ -51,8 +53,13 @@ namespace RandomFileRunner.IO directoryList.Add(item); } - foreach (string item in Directory.EnumerateFiles(directory, pattern, SearchOption.TopDirectoryOnly)) + foreach (string item in Directory.EnumerateFiles(directory, "*", SearchOption.TopDirectoryOnly)) { + if (!MatchFileSearchPattern(pattern, Path.GetFileName(item))) + { + continue; + } + if (!IsFileAccessible(item)) { continue;