ProgressStream

Ecng.IO

Stream wrapper that reports progress during read or write operations.

Erbt von: Stream

Konstruktoren

ProgressStream
public ProgressStream(Stream inner, long totalBytes, Action<int> progress, bool trackReads, bool trackWrites, bool leaveOpen)
progressStream = ProgressStream(inner, totalBytes, progress, trackReads, trackWrites, leaveOpen)

Initializes a new instance of ProgressStream.

inner
The underlying stream to wrap.
totalBytes
Total bytes expected (for percentage calculation).
progress
Callback invoked with progress percentage (0-100).
trackReads
Track progress on read operations.
trackWrites
Track progress on write operations.
leaveOpen
Whether to leave the inner stream open when disposed.

Eigenschaften

CanRead
public override bool CanRead { get; }
value = progressStream.CanRead

Gets a value indicating whether the current stream supports reading.

CanSeek
public override bool CanSeek { get; }
value = progressStream.CanSeek

Gets a value indicating whether the current stream supports seeking.

CanWrite
public override bool CanWrite { get; }
value = progressStream.CanWrite

Gets a value indicating whether the current stream supports writing.

LastReportedPercent
public int LastReportedPercent { get; }
value = progressStream.LastReportedPercent

Gets the last reported progress percentage.

Length
public override long Length { get; }
value = progressStream.Length

Gets the difference between the maximum and minimum values of the range.

Position
public override long Position { get; set; }
value = progressStream.Position
progressStream.Position = value

Current position value.

ProcessedBytes
public long ProcessedBytes { get; }
value = progressStream.ProcessedBytes

Gets the total bytes processed so far.

Methoden

CopyToAsync
public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
result = progressStream.CopyToAsync(destination, bufferSize, cancellationToken)
Dispose
protected override void Dispose(bool disposing)
progressStream.Dispose(disposing)

Disposes the command resources.

disposing
True if disposing managed resources.
Flush
public override void Flush()
progressStream.Flush()

Flushes the current byte to the underlying stream and resets the buffer.

FlushAsync
public override Task FlushAsync(CancellationToken cancellationToken)
result = progressStream.FlushAsync(cancellationToken)

Flushes the stream asynchronously.

cancellationToken
CancellationToken

Rückgabe: Task

Read
public override int Read(Span<byte> buffer)
result = progressStream.Read(buffer)
Read
public override int Read(byte[] buffer, int offset, int count)
result = progressStream.Read(buffer, offset, count)

Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

buffer
An array of bytes. When this method returns, the buffer contains the specified byte array with the values between and ( + - 1) replaced by the bytes read from the current source.
offset
The zero-based byte offset in at which to begin storing the data read from the current stream.
count
The maximum number of bytes to be read from the current stream.

Rückgabe: The total number of bytes read into the buffer.

ReadAsync
public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken)
result = progressStream.ReadAsync(buffer, cancellationToken)
ReadAsync
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
result = progressStream.ReadAsync(buffer, offset, count, cancellationToken)
ReadByte
public override int ReadByte()
result = progressStream.ReadByte()

Reads a byte from the current position and advances the position by 1 byte.

Rückgabe: The byte at the current position.

Seek
public override long Seek(long offset, SeekOrigin origin)
result = progressStream.Seek(offset, origin)

When overridden in a derived class, sets the position within the current stream.

offset
A byte offset relative to the parameter.
origin
A value of type SeekOrigin indicating the reference point used to obtain the new position.

Rückgabe: The new position within the current stream.

SetLength
public override void SetLength(long value)
progressStream.SetLength(value)

When overridden in a derived class, sets the length of the current stream.

value
The desired length of the current stream in bytes.
Write
public override void Write(byte[] buffer, int offset, int count)
progressStream.Write(buffer, offset, count)

Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

buffer
An array of bytes. This method copies bytes from to the current stream.
offset
The zero-based byte offset in at which to begin copying bytes to the current stream.
count
The number of bytes to be written to the current stream.
Write
public override void Write(ReadOnlySpan<byte> buffer)
progressStream.Write(buffer)
WriteAsync
public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken)
result = progressStream.WriteAsync(buffer, cancellationToken)
WriteAsync
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
result = progressStream.WriteAsync(buffer, offset, count, cancellationToken)
WriteByte
public override void WriteByte(byte value)
progressStream.WriteByte(value)

Writes a byte value to the span at the current position and advances the position.

value
The byte value to write.