Class ReadFile
Reads a file from disk to a stream.
Implements
Inherited Members
Namespace: NanoByte.Common.Storage
Assembly: NanoByte.Common.dll
Syntax
public sealed class ReadFile : TaskBase, ITask
Constructors
ReadFile(String, Action<Stream>, String)
Creates a new file read task.
Declaration
public ReadFile(string path, Action<Stream> callback, string name = null)
Parameters
Type | Name | Description |
---|---|---|
String | path | The path of the file to read. |
Action<Stream> | callback | Called with a stream providing the file content. |
String | name | A name describing the task in human-readable form. |
Properties
Name
A name describing the task in human-readable form.
Declaration
public override string Name { get; }
Property Value
Type | Description |
---|---|
String |
Overrides
UnitsByte
true
if UnitsProcessed and UnitsTotal are measured in bytes;
false
if they are measured in generic units.
Declaration
protected override bool UnitsByte { get; }
Property Value
Type | Description |
---|---|
Boolean |
Overrides
Methods
Execute()
The actual code to be executed.
Declaration
protected override void Execute()
Overrides
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
Type | Condition |
---|---|
OperationCanceledException | The operation was canceled. |
IOException | The task ended with IOError. |
WebException | The task ended with WebError. |