IFileSystem Interface
Provides an abstraction for file system operations, enabling testability and custom file access implementations.
public interface IFileSystemMethods
| Name | Description |
|---|---|
| GetFiles(string, string, SearchOption) | Gets the files in a directory matching the specified pattern. |
| OpenRead(string) | Opens a file for reading. |
| OpenReadWrite(string) | Opens a file for reading and writing. |
GetFiles(string, string, SearchOption)
Gets the files in a directory matching the specified pattern.
IEnumerable<string> GetFiles(string path, string pattern, SearchOption searchOptions)Parameters
pathstring- The directory path to search.
patternstring- The search pattern to match file names.
searchOptionsSearchOption- Options controlling the search behavior.
Returns
IEnumerable<string> An enumerable collection of file paths.
Remarks
A directory scan with a custom file system calls this method with the * pattern to list the files to scan, and SearchOption.AllDirectories when ScannerOptions.RecurseSubdirectories is set. It should throw a DirectoryNotFoundException when the directory does not exist, which the scan then reports.
OpenRead(string)
OpenReadWrite(string)
Opens a file for reading and writing.
Parameters
pathstring- The path to the file to open.
Returns
Stream A stream for reading and writing the file.
Remarks
The stream must be seekable and support Stream.SetLength, because an update reads the whole file, then rewrites it from its start and truncates it to the new length.