diff --git a/TruePath.SystemIo/PathIo.cs b/TruePath.SystemIo/PathIo.cs index 5aad759..1f96286 100644 --- a/TruePath.SystemIo/PathIo.cs +++ b/TruePath.SystemIo/PathIo.cs @@ -771,4 +771,55 @@ public static class PathIo /// One of the enumeration values that specifies whether the search operation should include only the current directory or should include all subdirectories. /// An array of the full names (including paths) for the subdirectories in the specified directory that match the specified search pattern and option. public static string[] GetDirectories(this AbsolutePath path, string searchPattern, SearchOption searchOption) => Directory.GetDirectories(path.Value, searchPattern, searchOption); + + /// + /// Returns an enumerable collection of of full file names in a specified path. + /// + /// The directory to search. + /// An enumerable collection of of the full names (including paths) for the files in the specified directory that match the specified search pattern. + public static IEnumerable EnumerateFiles(this AbsolutePath path) + { + return Directory.EnumerateFiles(path.Value) + .Select(filename => path / filename); + } + + /// + /// Returns an enumerable collection of of full file names in a specified path. + /// + /// The directory to search. + /// The search string to match against the names of files in . + /// An enumerable collection of of the full names (including paths) for the files in the specified directory that match the specified search pattern. + public static IEnumerable EnumerateFiles(this AbsolutePath path, string searchPattern) + { + return Directory.EnumerateFiles(path.Value, searchPattern) + .Select(filename => path / filename); + } + +#if NET8_0_OR_GREATER + /// + /// Returns an enumerable collection of of the names of files (including their paths) that match the specified search pattern and enumeration options in the specified directory. + /// + /// The directory to search. + /// The search string to match against the names of files in . + /// An object that contains the search options to use. + /// An enumerable collection of of the full names (including paths) for the files in the specified directory that match the specified search pattern and enumeration options. + public static IEnumerable EnumerateFiles(this AbsolutePath path, string searchPattern, EnumerationOptions enumerationOptions) + { + return Directory.EnumerateFiles(path.Value, searchPattern, enumerationOptions) + .Select(filename => path / filename); + } +#endif + + /// + /// Returns an enumerable collection of with the names of files (including their paths) that match the specified search pattern in the specified directory, using a value to determine whether to search subdirectories. + /// + /// The directory to search. + /// The search string to match against the names of files in . + /// One of the enumeration values that specifies whether the search operation should include only the current directory or should include all subdirectories. + /// An enumerable collection of of the full names (including paths) for the files in the specified directory that match the specified search pattern. + public static IEnumerable EnumerateFiles(this AbsolutePath path, string searchPattern, SearchOption searchOption) + { + return Directory.EnumerateFiles(path.Value, searchPattern, searchOption) + .Select(filename => path / filename); + } }