Class FolderOutputHandler

FolderOutputHandler class

An implementation of IOutputHandler that writes output streams to files in a specified folder.

public class FolderOutputHandler : IOutputHandler

Constructors

NameDescription
FolderOutputHandler(string)Initializes a new instance of the FolderOutputHandler class with the specified output folder path.

Properties

NameDescription
Path { get; set; }Gets or sets the target folder path where output files will be written.

Methods

NameDescription
AddOutputStream(string, Action<Stream>)
AddOutputStream(string, Func<Stream, Task>)

Examples

Example usage:

var outputHandler = new FolderOutputHandler("C:\\Output");
await outputHandler.AddOutputStream("example.txt", async stream =>
{
    using var writer = new StreamWriter(stream);
    await writer.WriteLineAsync("Hello from async!");
});

outputHandler.AddOutputStream("example_sync.txt", stream =>
{
    using var writer = new StreamWriter(stream);
    writer.WriteLine("Hello from sync!");
});

See Also