Interface IFileOperations

Assembly: redb.Route.GenericFile.dll

Abstraction for file system operations. Implementations adapt
concrete I/O APIs (System.IO, SSH.NET, FluentFTP) to a uniform interface.
All path operations are protocol-aware (forward-slash for remote, OS-native for local).

public interface IFileOperations

Methods

AppendAsync(string, byte[], CancellationToken)

Appends data to an existing file.

Task AppendAsync(string path, byte[] data, CancellationToken ct = default)

AppendTextAsync(string, string, Encoding, CancellationToken)

Appends text to an existing file.

Task AppendTextAsync(string path, string text, Encoding encoding, CancellationToken ct = default)

CombinePath(string, string)

Combines a base path and a relative path using the appropriate separator.

string CombinePath(string basePath, string relativePath)

CreateDirectoryAsync(string, CancellationToken)

Creates a directory (and all parent directories if missing).

Task CreateDirectoryAsync(string path, CancellationToken ct = default)

DeleteAsync(string, CancellationToken)

Deletes a file.

Task DeleteAsync(string path, CancellationToken ct = default)

DirectoryExistsAsync(string, CancellationToken)

Checks whether a directory exists.

Task<bool> DirectoryExistsAsync(string path, CancellationToken ct = default)

ExistsAsync(string, CancellationToken)

Checks whether a file or directory exists.

Task<bool> ExistsAsync(string path, CancellationToken ct = default)

GetExtension(string)

Returns the extension including the dot (e.g. ".csv").

string GetExtension(string name)

GetFileName(string)

Returns the file name from a path.

string GetFileName(string path)

GetFileNameWithoutExtension(string)

Returns the file name without extension.

string GetFileNameWithoutExtension(string name)

GetParentPath(string)

Returns the parent directory of the given path.

string GetParentPath(string path)

GetRelativePath(string, string)

Returns the relative path from basePath to fullPath.

string GetRelativePath(string basePath, string fullPath)

IsAbsolutePath(string)

Checks whether the given path is absolute.

bool IsAbsolutePath(string path)

ListFilesAsync(string, bool, int, int, Func<string, string, bool>?, CancellationToken)

Lists files in the given directory.

Task<List<GenericFileInfo>> ListFilesAsync(string directory, bool recursive, int maxDepth, int minDepth, Func<string, string, bool>? directoryFilter = null, CancellationToken ct = default)

MoveAsync(string, string, bool, CancellationToken)

Moves (renames) a file from source to destination.

Task MoveAsync(string source, string destination, bool overwrite, CancellationToken ct = default)

OpenReadAsync(string, CancellationToken)

Opens a read stream to the file. Caller is responsible for disposing.

Task<Stream> OpenReadAsync(string path, CancellationToken ct = default)

ReadAllBytesAsync(string, CancellationToken)

Reads the entire file into a byte array.

Task<byte[]> ReadAllBytesAsync(string path, CancellationToken ct = default)

WriteAsync(string, byte[], CancellationToken)

Writes data to a file, creating or overwriting it.

Task WriteAsync(string path, byte[] data, CancellationToken ct = default)

WriteAsync(string, Stream, CancellationToken)

Writes a stream to a file, creating or overwriting it.

Task WriteAsync(string path, Stream data, CancellationToken ct = default)