Table of Contents

Class ReadFile

Namespace
NanoByte.Common.Storage
Assembly
NanoByte.Common.dll

Reads a file from disk to a stream.

public sealed class ReadFile : TaskBase, ITask
Inheritance
object
MarshalByRefObject
ReadFile
Implements
Inherited Members
Extension Methods

Constructors

ReadFile(string, Action<Stream>, string?)

Reads a file from disk to a stream.

public ReadFile(string path, Action<Stream> callback, string? name = null)

Parameters

path string

The path of the file to read.

callback Action<Stream>

Called with a stream providing the file content.

name string

A name describing the task in human-readable form.

Properties

Name

A name describing the task in human-readable form.

public override string Name { get; }

Property Value

string

UnitsByte

true if UnitsProcessed and UnitsTotal are measured in bytes; false if they are measured in generic units.

protected override bool UnitsByte { get; }

Property Value

bool

Methods

Execute()

The actual code to be executed.

protected override void Execute()

Remarks

State is automatically set to Started before calling this method, to Complete after a successful exit and to an appropriate error state in case on an exception. You can set additional TaskStates during execution.

Exceptions

OperationCanceledException

The operation was canceled.

IOException

The task ended with IOError.

WebException

The task ended with WebError.