Search Results for

    Show / Hide Table of Contents

    Class StreamUtil

    Inheritance
    object
    StreamUtil
    Inherited Members
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: Reportman.Drawing
    Assembly: Reportman.Drawing.dll
    Syntax
    public class StreamUtil

    Constructors

    StreamUtil()

    Declaration
    public StreamUtil()

    Fields

    CRLFarray

    Declaration
    public static byte[] CRLFarray
    Field Value
    Type Description
    byte[]

    DEFAULT_BUFFER_SIZE

    Default buffer size for buffered applications

    Declaration
    public const int DEFAULT_BUFFER_SIZE = 65535
    Field Value
    Type Description
    int

    LFarray

    Declaration
    public static byte[] LFarray
    Field Value
    Type Description
    byte[]

    Methods

    BoolToByteArray(bool)

    Converts a bool to a byte array

    Declaration
    public static byte[] BoolToByteArray(bool avalue)
    Parameters
    Type Name Description
    bool avalue
    Returns
    Type Description
    byte[]

    ByteArrayToInt(byte[], int)

    Converts a byte array to an int value

    Declaration
    public static int ByteArrayToInt(byte[] b1, int alen)
    Parameters
    Type Name Description
    byte[] b1
    int alen
    Returns
    Type Description
    int

    ByteArrayToInt(byte[], int, int)

    Converts a byte array to an int value

    Declaration
    public static int ByteArrayToInt(byte[] b1, int index, int alen)
    Parameters
    Type Name Description
    byte[] b1
    int index
    int alen
    Returns
    Type Description
    int

    ByteArrayToInt64(byte[], int, int)

    Converts a byte array to an int64 value

    Declaration
    public static long ByteArrayToInt64(byte[] b1, int index, int alen)
    Parameters
    Type Name Description
    byte[] b1
    int index
    int alen
    Returns
    Type Description
    long

    ByteArrayToLong(byte[], int)

    Converts a byte array to a long value

    Declaration
    public static long ByteArrayToLong(byte[] b1, int alen)
    Parameters
    Type Name Description
    byte[] b1
    int alen
    Returns
    Type Description
    long

    ByteArrayToLong(byte[], int, int)

    Converts a byte array to a long value

    Declaration
    public static long ByteArrayToLong(byte[] b1, int index, int alen)
    Parameters
    Type Name Description
    byte[] b1
    int index
    int alen
    Returns
    Type Description
    long

    ByteArrayToShort(byte[], int)

    Converts a byte array to a short value

    Declaration
    public static short ByteArrayToShort(byte[] b1, int alen)
    Parameters
    Type Name Description
    byte[] b1
    int alen
    Returns
    Type Description
    short

    ByteArrayToShort(byte[], int, int)

    Converts a byte array to a short value

    Declaration
    public static short ByteArrayToShort(byte[] b1, int index, int alen)
    Parameters
    Type Name Description
    byte[] b1
    int index
    int alen
    Returns
    Type Description
    short

    ByteArrayToStream(byte[])

    Converts a byte array to a MemoryStream

    Declaration
    public static MemoryStream ByteArrayToStream(byte[] b1)
    Parameters
    Type Name Description
    byte[] b1
    Returns
    Type Description
    MemoryStream

    ByteArrayToString(byte[], int)

    Converts a byte array to a string (not unicode)

    Declaration
    public static string ByteArrayToString(byte[] b1, int alen)
    Parameters
    Type Name Description
    byte[] b1
    int alen
    Returns
    Type Description
    string

    ByteArrayToString(byte[], int, bool)

    Converts a byte array to a string, choosing unicode

    Declaration
    public static string ByteArrayToString(byte[] b1, int alen, bool unicode)
    Parameters
    Type Name Description
    byte[] b1
    int alen
    bool unicode
    Returns
    Type Description
    string

    ByteArrayToString(byte[], int, int)

    Converts a byte array to a string (not unicode)

    Declaration
    public static string ByteArrayToString(byte[] b1, int nindex, int alen)
    Parameters
    Type Name Description
    byte[] b1
    int nindex
    int alen
    Returns
    Type Description
    string

    ByteArrayToUInt(byte[], int, int)

    Converts a byte array to an uint value

    Declaration
    public static uint ByteArrayToUInt(byte[] b1, int index, int alen)
    Parameters
    Type Name Description
    byte[] b1
    int index
    int alen
    Returns
    Type Description
    uint

    ByteArrayToUShort(byte[], int, int)

    Converts a byte array to an ushort value

    Declaration
    public static ushort ByteArrayToUShort(byte[] b1, int index, int alen)
    Parameters
    Type Name Description
    byte[] b1
    int index
    int alen
    Returns
    Type Description
    ushort

    ByteToByteArray(byte)

    Converts a byte to a byte array

    Declaration
    public static byte[] ByteToByteArray(byte avalue)
    Parameters
    Type Name Description
    byte avalue
    Returns
    Type Description
    byte[]

    CompareArrayContent(byte[], byte[])

    Compare the content of two byte arrays, returns true if the content is the same

    Declaration
    public static bool CompareArrayContent(byte[] b1, byte[] b2)
    Parameters
    Type Name Description
    byte[] b1
    byte[] b2
    Returns
    Type Description
    bool

    CompressFile(string, string)

    Declaration
    public static void CompressFile(string source, string destination)
    Parameters
    Type Name Description
    string source
    string destination

    CompressStream(MemoryStream, MemoryStream, bool)

    Compress the first memory stream into the second memory stream, option for optimize size

    Declaration
    public static void CompressStream(MemoryStream memstream, MemoryStream dest, bool optimizesize)
    Parameters
    Type Name Description
    MemoryStream memstream
    MemoryStream dest
    bool optimizesize

    CompressStream(Stream, MemoryStream)

    Compress the first memory stream into the second memory stream

    Declaration
    public static void CompressStream(Stream memstream, MemoryStream dest)
    Parameters
    Type Name Description
    Stream memstream
    MemoryStream dest

    CompressStreamAsync(MemoryStream, MemoryStream)

    Compress the first memory stream into the second memory stream

    Declaration
    public static Task CompressStreamAsync(MemoryStream memstream, MemoryStream dest)
    Parameters
    Type Name Description
    MemoryStream memstream
    MemoryStream dest
    Returns
    Type Description
    Task

    CompressStreamAsync(MemoryStream, MemoryStream, bool, bool, CancellationTokenSource)

    Declaration
    public static Task<TaskCompressResult> CompressStreamAsync(MemoryStream memstream, MemoryStream dest, bool optimizesize, bool disposeSource, CancellationTokenSource cancelSource)
    Parameters
    Type Name Description
    MemoryStream memstream
    MemoryStream dest
    bool optimizesize
    bool disposeSource
    CancellationTokenSource cancelSource
    Returns
    Type Description
    Task<TaskCompressResult>

    CompressStreamGZip(MemoryStream, MemoryStream)

    Compress the first memory stream into the second memory stream using Gzip

    Declaration
    public static void CompressStreamGZip(MemoryStream memstream, MemoryStream dest)
    Parameters
    Type Name Description
    MemoryStream memstream
    MemoryStream dest

    CompressStreamGZipAsync(MemoryStream, MemoryStream)

    Compress the first memory stream into the second memory stream using Gzip

    Declaration
    public static Task CompressStreamGZipAsync(MemoryStream memstream, MemoryStream dest)
    Parameters
    Type Name Description
    MemoryStream memstream
    MemoryStream dest
    Returns
    Type Description
    Task

    CompressStreamTask(MemoryStream, MemoryStream, bool, bool, CancellationTokenSource)

    Declaration
    public static Task<TaskCompressResult> CompressStreamTask(MemoryStream memstream, MemoryStream dest, bool optimizesize, bool disposeSource, CancellationTokenSource cancelSource)
    Parameters
    Type Name Description
    MemoryStream memstream
    MemoryStream dest
    bool optimizesize
    bool disposeSource
    CancellationTokenSource cancelSource
    Returns
    Type Description
    Task<TaskCompressResult>

    DeCompressBuffer(byte[], int, Stream)

    Dercompress the first memory stream into the second memory stream

    Declaration
    public static void DeCompressBuffer(byte[] buffer, int count, Stream dest)
    Parameters
    Type Name Description
    byte[] buffer
    int count
    Stream dest

    DeCompressBuffer(byte[], int, Stream, ProgressEvent)

    Dercompress the first memory stream into the second memory stream

    Declaration
    public static void DeCompressBuffer(byte[] buffer, int count, Stream dest, ProgressEvent progevent)
    Parameters
    Type Name Description
    byte[] buffer
    int count
    Stream dest
    ProgressEvent progevent

    DeCompressBufferAsync(byte[], int, Stream)

    Dercompress the first memory stream into the second memory stream

    Declaration
    public static Task DeCompressBufferAsync(byte[] buffer, int count, Stream dest)
    Parameters
    Type Name Description
    byte[] buffer
    int count
    Stream dest
    Returns
    Type Description
    Task

    DeCompressBufferAsync(byte[], int, Stream, ProgressEvent)

    net Dercompress the first memory stream into the second memory stream

    Declaration
    public static Task DeCompressBufferAsync(byte[] buffer, int count, Stream dest, ProgressEvent progevent)
    Parameters
    Type Name Description
    byte[] buffer
    int count
    Stream dest
    ProgressEvent progevent
    Returns
    Type Description
    Task

    DeCompressBufferGZip(byte[], int, int, Stream)

    Dercompress the first memory stream into the second memory stream

    Declaration
    public static void DeCompressBufferGZip(byte[] buffer, int offset, int count, Stream dest)
    Parameters
    Type Name Description
    byte[] buffer
    int offset
    int count
    Stream dest

    DeCompressBufferGZipAsync(byte[], int, int, Stream)

    Dercompress the first memory stream into the second memory stream

    Declaration
    public static Task DeCompressBufferGZipAsync(byte[] buffer, int offset, int count, Stream dest)
    Parameters
    Type Name Description
    byte[] buffer
    int offset
    int count
    Stream dest
    Returns
    Type Description
    Task

    DeCompressFile(string, string)

    Declaration
    public static void DeCompressFile(string source, string destination)
    Parameters
    Type Name Description
    string source
    string destination

    DeCompressStream(MemoryStream, MemoryStream)

    Dercompress the first memory stream into the second memory stream

    Declaration
    public static void DeCompressStream(MemoryStream memstream, MemoryStream dest)
    Parameters
    Type Name Description
    MemoryStream memstream
    MemoryStream dest

    DecompressStreamGZip(Stream, Stream)

    Declaration
    public static void DecompressStreamGZip(Stream origin, Stream dest)
    Parameters
    Type Name Description
    Stream origin
    Stream dest

    DecompressStreamGZipAsync(Stream, Stream)

    Declaration
    public static Task DecompressStreamGZipAsync(Stream origin, Stream dest)
    Parameters
    Type Name Description
    Stream origin
    Stream dest
    Returns
    Type Description
    Task

    FileInUse(string)

    Check for a file if in use return true

    Declaration
    public static bool FileInUse(string path)
    Parameters
    Type Name Description
    string path
    Returns
    Type Description
    bool

    FileToMemoryStream(string)

    Generates a MemoryStream from a file

    Declaration
    public static MemoryStream FileToMemoryStream(string filename)
    Parameters
    Type Name Description
    string filename
    Returns
    Type Description
    MemoryStream

    FileToMemoryStreamAsync(string)

    Generates a MemoryStream from a file

    Declaration
    public static Task<MemoryStream> FileToMemoryStreamAsync(string filename)
    Parameters
    Type Name Description
    string filename
    Returns
    Type Description
    Task<MemoryStream>

    GetFiles(string, string, SearchOption)

    Declaration
    public static string[] GetFiles(string path, string searchPattern, SearchOption searchOption)
    Parameters
    Type Name Description
    string path
    string searchPattern
    SearchOption searchOption
    Returns
    Type Description
    string[]

    Int64ToByteArray(long)

    Converts an int to a byte array

    Declaration
    public static byte[] Int64ToByteArray(long avalue)
    Parameters
    Type Name Description
    long avalue
    Returns
    Type Description
    byte[]

    IntToByteArray(int)

    Converts an int to a byte array

    Declaration
    public static byte[] IntToByteArray(int avalue)
    Parameters
    Type Name Description
    int avalue
    Returns
    Type Description
    byte[]

    IsCompressed(byte[])

    Check if the stream is a compressed stream

    Declaration
    public static bool IsCompressed(byte[] buf)
    Parameters
    Type Name Description
    byte[] buf
    Returns
    Type Description
    bool

    IsCompressed(MemoryStream)

    Check if the stream is a compressed stream

    Declaration
    public static bool IsCompressed(MemoryStream mems)
    Parameters
    Type Name Description
    MemoryStream mems
    Returns
    Type Description
    bool

    LongToByteArray(long)

    Converts a long value to a byte array to a long value

    Declaration
    public static byte[] LongToByteArray(long avalue)
    Parameters
    Type Name Description
    long avalue
    Returns
    Type Description
    byte[]

    MemoryStreamToFile(MemoryStream, string)

    Generate a file from a memory stream

    Declaration
    public static void MemoryStreamToFile(MemoryStream memstream, string filename)
    Parameters
    Type Name Description
    MemoryStream memstream
    string filename

    SWriteLine(Stream, string, bool)

    Write a string to a stream, the string should contain only single byte characters

    Declaration
    public static void SWriteLine(Stream astream, string astring, bool includeCR = false)
    Parameters
    Type Name Description
    Stream astream
    string astring
    bool includeCR

    ShortToByteArray(int)

    Converts a short to a byte array

    Declaration
    public static byte[] ShortToByteArray(int avalue)
    Parameters
    Type Name Description
    int avalue
    Returns
    Type Description
    byte[]

    StreamToFile(Stream, string, bool)

    Generate a file from a stream

    Declaration
    public static void StreamToFile(Stream memstream, string filename, bool overwrite)
    Parameters
    Type Name Description
    Stream memstream
    string filename
    bool overwrite

    StreamToFileAsync(Stream, string, bool)

    Generate a file from a stream

    Declaration
    public static void StreamToFileAsync(Stream memstream, string filename, bool overwrite)
    Parameters
    Type Name Description
    Stream memstream
    string filename
    bool overwrite

    StreamToHex(Stream)

    Transforms stream content to string representation as hexadecimal bytes

    Declaration
    public static string StreamToHex(Stream astream)
    Parameters
    Type Name Description
    Stream astream
    Returns
    Type Description
    string

    StreamToMemoryStream(Stream)

    Generates a MemoryStream from any Stream input

    Declaration
    public static MemoryStream StreamToMemoryStream(Stream astream)
    Parameters
    Type Name Description
    Stream astream
    Returns
    Type Description
    MemoryStream

    StreamToMemoryStream(Stream, int)

    Generates a MemoryStream from any Stream input

    Declaration
    public static MemoryStream StreamToMemoryStream(Stream astream, int bufsize)
    Parameters
    Type Name Description
    Stream astream

    Source stream

    int bufsize

    Buffer size can be specified size for performance enhacement when handling long streams. You can specify 0 value, so the DEFAULT_BUFFER_SIZE (65535) will be used. Note that standard input does not allow reading long segments so keep the default value if you don't know the source stream procedence

    Returns
    Type Description
    MemoryStream

    The resulting memory stream

    StreamToMemoryStreamAsync(Stream, int)

    Generates a MemoryStream from any Stream input

    Declaration
    public static Task<MemoryStream> StreamToMemoryStreamAsync(Stream astream, int bufsize)
    Parameters
    Type Name Description
    Stream astream

    Source stream

    int bufsize

    Buffer size can be specified size for performance enhacement when handling long streams. You can specify 0 value, so the DEFAULT_BUFFER_SIZE (65535) will be used. Note that standard input does not allow reading long segments so keep the default value if you don't know the source stream procedence

    Returns
    Type Description
    Task<MemoryStream>

    The resulting memory stream

    StringToByteArray(string, int)

    Converts a string (not unicode) to a byte array the array is created with the first byte of the char value only ANSI alowed

    Declaration
    public static byte[] StringToByteArray(string avalue, int length)
    Parameters
    Type Name Description
    string avalue
    int length
    Returns
    Type Description
    byte[]

    StringToByteArray(string, int, bool)

    Converts a string to a byte array, choosing unicode or not

    Declaration
    public static byte[] StringToByteArray(string avalue, int length, bool unicode)
    Parameters
    Type Name Description
    string avalue
    int length
    bool unicode
    Returns
    Type Description
    byte[]

    StringToByteArray(string, int, int)

    Converts a string (not unicode) to a byte array

    Declaration
    public static byte[] StringToByteArray(string avalue, int length, int codepage)
    Parameters
    Type Name Description
    string avalue
    int length
    int codepage
    Returns
    Type Description
    byte[]

    WriteCharArrayToStream(char[], int, Stream)

    Writes a string to a stream formatted as multibyte UFT8 encondig

    Declaration
    public static int WriteCharArrayToStream(char[] chars, int len, Stream astream)
    Parameters
    Type Name Description
    char[] chars
    int len
    Stream astream
    Returns
    Type Description
    int

    WriteStringToStream(string, Stream, Encoding)

    Writes a string to a stream formatted as multibyte UFT8 encondig

    Declaration
    public static int WriteStringToStream(string astring, Stream astream, Encoding nencoding)
    Parameters
    Type Name Description
    string astring
    Stream astream
    Encoding nencoding
    Returns
    Type Description
    int

    WriteStringToUTF8Stream(string, Stream)

    Writes a string to a stream formatted as multibyte UFT8 encondig

    Declaration
    public static int WriteStringToUTF8Stream(string astring, Stream astream)
    Parameters
    Type Name Description
    string astring
    Stream astream
    Returns
    Type Description
    int

    WriteTo(Stream, Stream, int)

    Declaration
    public static void WriteTo(Stream from, Stream to, int bufSize = 32000)
    Parameters
    Type Name Description
    Stream from
    Stream to
    int bufSize
    In this article
    Back to top Generated by DocFX