Class StreamUtil
Assembly: Reportman.Drawing.dll
Syntax
Constructors
StreamUtil()
Declaration
Fields
CRLFarray
Declaration
public static byte[] CRLFarray
Field Value
DEFAULT_BUFFER_SIZE
Default buffer size for buffered applications
Declaration
public const int DEFAULT_BUFFER_SIZE = 65535
Field Value
LFarray
Declaration
public static byte[] LFarray
Field Value
Methods
BoolToByteArray(bool)
Converts a bool to a byte array
Declaration
public static byte[] BoolToByteArray(bool avalue)
Parameters
| Type |
Name |
Description |
| bool |
avalue |
|
Returns
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
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
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
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
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
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
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
ByteArrayToStream(byte[])
Converts a byte array to a MemoryStream
Declaration
public static MemoryStream ByteArrayToStream(byte[] b1)
Parameters
| Type |
Name |
Description |
| byte[] |
b1 |
|
Returns
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
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
Returns
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
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
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
ByteToByteArray(byte)
Converts a byte to a byte array
Declaration
public static byte[] ByteToByteArray(byte avalue)
Parameters
| Type |
Name |
Description |
| byte |
avalue |
|
Returns
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
CompressFile(string, string)
Declaration
public static void CompressFile(string source, string destination)
Parameters
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
CompressStream(Stream, MemoryStream)
Compress the first memory stream into the second memory stream
Declaration
public static void CompressStream(Stream memstream, MemoryStream dest)
Parameters
CompressStreamAsync(MemoryStream, MemoryStream)
Compress the first memory stream into the second memory stream
Declaration
public static Task CompressStreamAsync(MemoryStream memstream, MemoryStream dest)
Parameters
Returns
CompressStreamAsync(MemoryStream, MemoryStream, bool, bool, CancellationTokenSource)
Declaration
public static Task<TaskCompressResult> CompressStreamAsync(MemoryStream memstream, MemoryStream dest, bool optimizesize, bool disposeSource, CancellationTokenSource cancelSource)
Parameters
Returns
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
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
Returns
CompressStreamTask(MemoryStream, MemoryStream, bool, bool, CancellationTokenSource)
Declaration
public static Task<TaskCompressResult> CompressStreamTask(MemoryStream memstream, MemoryStream dest, bool optimizesize, bool disposeSource, CancellationTokenSource cancelSource)
Parameters
Returns
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
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
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
Returns
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
Returns
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
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
Returns
DeCompressFile(string, string)
Declaration
public static void DeCompressFile(string source, string destination)
Parameters
DeCompressStream(MemoryStream, MemoryStream)
Dercompress the first memory stream into the second memory stream
Declaration
public static void DeCompressStream(MemoryStream memstream, MemoryStream dest)
Parameters
DecompressStreamGZip(Stream, Stream)
Declaration
public static void DecompressStreamGZip(Stream origin, Stream dest)
Parameters
DecompressStreamGZipAsync(Stream, Stream)
Declaration
public static Task DecompressStreamGZipAsync(Stream origin, Stream dest)
Parameters
Returns
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
FileToMemoryStream(string)
Generates a MemoryStream from a file
Declaration
public static MemoryStream FileToMemoryStream(string filename)
Parameters
| Type |
Name |
Description |
| string |
filename |
|
Returns
FileToMemoryStreamAsync(string)
Generates a MemoryStream from a file
Declaration
public static Task<MemoryStream> FileToMemoryStreamAsync(string filename)
Parameters
| Type |
Name |
Description |
| string |
filename |
|
Returns
GetFiles(string, string, SearchOption)
Declaration
public static string[] GetFiles(string path, string searchPattern, SearchOption searchOption)
Parameters
Returns
Int64ToByteArray(long)
Converts an int to a byte array
Declaration
public static byte[] Int64ToByteArray(long avalue)
Parameters
| Type |
Name |
Description |
| long |
avalue |
|
Returns
IntToByteArray(int)
Converts an int to a byte array
Declaration
public static byte[] IntToByteArray(int avalue)
Parameters
| Type |
Name |
Description |
| int |
avalue |
|
Returns
IsCompressed(byte[])
Check if the stream is a compressed stream
Declaration
public static bool IsCompressed(byte[] buf)
Parameters
| Type |
Name |
Description |
| byte[] |
buf |
|
Returns
IsCompressed(MemoryStream)
Check if the stream is a compressed stream
Declaration
public static bool IsCompressed(MemoryStream mems)
Parameters
Returns
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
MemoryStreamToFile(MemoryStream, string)
Generate a file from a memory stream
Declaration
public static void MemoryStreamToFile(MemoryStream memstream, string filename)
Parameters
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
ShortToByteArray(int)
Converts a short to a byte array
Declaration
public static byte[] ShortToByteArray(int avalue)
Parameters
| Type |
Name |
Description |
| int |
avalue |
|
Returns
StreamToFile(Stream, string, bool)
Generate a file from a stream
Declaration
public static void StreamToFile(Stream memstream, string filename, bool overwrite)
Parameters
StreamToFileAsync(Stream, string, bool)
Generate a file from a stream
Declaration
public static void StreamToFileAsync(Stream memstream, string filename, bool overwrite)
Parameters
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
StreamToMemoryStream(Stream)
Generates a MemoryStream from any Stream input
Declaration
public static MemoryStream StreamToMemoryStream(Stream astream)
Parameters
| Type |
Name |
Description |
| Stream |
astream |
|
Returns
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
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
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
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
Returns
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
Returns
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
Returns
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
Returns
WriteStringToUTF8Stream(string, Stream)
Writes a string to a stream formatted as multibyte UFT8 encondig
Declaration
public static int WriteStringToUTF8Stream(string astring, Stream astream)
Parameters
Returns
WriteTo(Stream, Stream, int)
Declaration
public static void WriteTo(Stream from, Stream to, int bufSize = 32000)
Parameters