menu

UWP

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class BufferedStreamEx - UWP API Reference | Syncfusion

    Show / Hide Table of Contents

    Class BufferedStreamEx

    Special wrapper class that allows users to control access to stream and cache data.

    Inheritance
    System.Object
    BufferedStreamEx
    Namespace: Syncfusion.CompoundFile.XlsIO.Native
    Assembly: Syncfusion.XlsIO.UWP.dll
    Syntax
    public class BufferedStreamEx : Stream

    Constructors

    BufferedStreamEx(Stream)

    Initialize class by stream and DefaultBufferSize == 4096.

    Declaration
    public BufferedStreamEx(Stream stream)
    Parameters
    Type Name Description
    System.IO.Stream stream

    Stream which our class must wrap.

    BufferedStreamEx(Stream, Int32)

    Initialize class by instance of stream and user defined cache size.

    Declaration
    public BufferedStreamEx(Stream stream, int bufferSize)
    Parameters
    Type Name Description
    System.IO.Stream stream

    Stream which our class must wrap.

    System.Int32 bufferSize

    User defined cache size.

    Exceptions
    Type Condition
    System.ArgumentException

    Stream does not support Read and Write operations.

    System.ArgumentOutOfRangeException

    BufferSize is equal or less than zero.

    Properties

    BaseStream

    Get reference of stream wrapped by BufferStreamEx.

    Declaration
    public Stream BaseStream { get; }
    Property Value
    Type
    System.IO.Stream

    CanRead

    Indicates whether data can be read from the wrapped stream. True if data can be read.

    Declaration
    public override bool CanRead { get; }
    Property Value
    Type
    System.Boolean
    Exceptions
    Type Condition
    System.ArgumentNullException

    Class instance was disposed.

    CanSeek

    Indicates whether the wrapped stream supports Seek operations.

    Declaration
    public override bool CanSeek { get; }
    Property Value
    Type
    System.Boolean
    Exceptions
    Type Condition
    System.ArgumentNullException

    Class instance was disposed.

    CanWrite

    Indicates whether data can be written to wrapped stream.

    Declaration
    public override bool CanWrite { get; }
    Property Value
    Type
    System.Boolean
    Exceptions
    Type Condition
    System.ArgumentNullException

    Class instance was disposed.

    Length

    Gets length of the wrapped stream. When this property is accessed, the data that is not written to the stream is first flushed.

    Declaration
    public override long Length { get; }
    Property Value
    Type
    System.Int64
    Exceptions
    Type Condition
    System.ArgumentNullException

    Class instance was disposed.

    Position

    Gets the current position of stream. Position can be different from the value in wrapped stream, because wrapped stream will point to the last byte of the cached data. When this property is set, the data that is not written is flushed to the stream.

    Declaration
    public override long Position { get; set; }
    Property Value
    Type
    System.Int64
    Exceptions
    Type Condition
    System.ArgumentNullException

    Class instance was disposed.

    System.ArgumentException

    Wrapped stream does not support seek operation.

    Methods

    Flush()

    Flushes data and resets the cache.

    Declaration
    public override void Flush()
    Exceptions
    Type Condition
    System.ArgumentNullException

    When stream is NULL.

    Read(Byte[], Int32, Int32)

    Reads data from the stream. If data is cached, the class will not call wrapped stream and will simply return a copy of cached data.

    Declaration
    public override int Read(byte[] array, int offset, int count)
    Parameters
    Type Name Description
    System.Byte[] array

    Output buffer.

    System.Int32 offset

    Offset in output buffer where data from stream must be placed.

    System.Int32 count

    Count of bytes which class must return.

    Returns
    Type Description
    System.Int32

    Quantity of read bytes.

    ReadByte()

    Reads a byte from the underlying stream. Returns an int (byte cast to an int) or -1 if it is the end of the stream.

    Declaration
    public override int ReadByte()
    Returns
    Type Description
    System.Int32

    Read byte.

    Seek(Int64, SeekOrigin)

    On any Seek operation, data not written from cache will be flushed to the wrapped stream. Using the Position property is better as it is optimized for cache use.

    Declaration
    public override long Seek(long offset, SeekOrigin origin)
    Parameters
    Type Name Description
    System.Int64 offset

    New offset of stream.

    System.IO.SeekOrigin origin

    Start point of seek operation.

    Returns
    Type Description
    System.Int64

    Current position.

    Exceptions
    Type Condition
    System.ArgumentNullException

    If stream is NULL.

    System.ArgumentException

    If can't seek in the stream.

    SetLength(Int64)

    Sets length of wrapped stream.

    Declaration
    public override void SetLength(long value)
    Parameters
    Type Name Description
    System.Int64 value

    New length of stream.

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    When value is less than zero.

    System.ArgumentNullException

    When stream is NULL.

    System.ArgumentException

    Cannot seek or cannot write into stream.

    Write(Byte[], Int32, Int32)

    Writes portion of data into a wrapped stream. Data will be cached if it is possible. It will then be saved to the wrapped stream on Flush.

    Declaration
    public override void Write(byte[] array, int offset, int count)
    Parameters
    Type Name Description
    System.Byte[] array

    Array containing data.

    System.Int32 offset

    Offset to the beginning of the portion of data.

    System.Int32 count

    Number of bytes in the portion of data.

    Exceptions
    Type Condition
    System.ArgumentNullException

    If array or stream is NULL.

    System.ArgumentOutOfRangeException

    If offset or count is less than zero.

    System.ArgumentException

    If array does not contain the required element count.

    WriteByte(Byte)

    Write one byte of information into stream.

    Declaration
    public override void WriteByte(byte value)
    Parameters
    Type Name Description
    System.Byte value

    Value which must be written.

    Exceptions
    Type Condition
    System.ArgumentNullException

    If stream is NULL.

    System.ArgumentException

    If can't write into stream.

    Extension Methods

    DateTimeExtension.ToDateTime(Object)
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved