Class IOExtensions
Implements I/O related class extensions.
Namespace: Neon.Common
Assembly: Neon.Common.dll
Syntax
public static class IOExtensions
Methods
DeflateTo(Stream, Stream)
Uses deflate to compress a source to a target stream.
Declaration
public static void DeflateTo(this Stream source, Stream target)
Parameters
Type | Name | Description |
---|---|---|
Stream | source | The source stream. |
Stream | target | The target stream. |
GunzipTo(Stream, Stream)
Uses GZIP to decompress a source to a target stream.
Declaration
public static void GunzipTo(this Stream source, Stream target)
Parameters
Type | Name | Description |
---|---|---|
Stream | source | The source stream. |
Stream | target | The target stream. |
GzipTo(Stream, Stream)
Uses GZIP to compress a source to a target stream.
Declaration
public static void GzipTo(this Stream source, Stream target)
Parameters
Type | Name | Description |
---|---|---|
Stream | source | The source stream. |
Stream | target | The target stream. |
InflateTo(Stream, Stream)
Uses deflate to decompress a source to a target stream.
Declaration
public static void InflateTo(this Stream source, Stream target)
Parameters
Type | Name | Description |
---|---|---|
Stream | source | The source stream. |
Stream | target | The target stream. |
Lines(TextReader, bool)
Returns an enumerator that returns the lines of text from a TextReader.
Declaration
public static IEnumerable<string> Lines(this TextReader reader, bool ignoreBlank = false)
Parameters
Type | Name | Description |
---|---|---|
TextReader | reader | The reader. |
bool | ignoreBlank | Optionally skip empty lines or lines with oly whitespace. |
Returns
Type | Description |
---|---|
IEnumerable<string> | The IEnumerable<T>. |
ReadBytes(Stream, int)
Reads the byte array from the current position, advancing the position past the value read.
Declaration
public static byte[] ReadBytes(this Stream stream, int cb)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream. |
int | cb | The number of bytes to read. |
Returns
Type | Description |
---|---|
byte[] | The byte array. Note that the array returned may have a length less than the size requested if the end of the file has been reached. |
ReadToEnd(Stream)
Reads all bytes from the current position to the end of the stream.
Declaration
public static byte[] ReadToEnd(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The source stream. |
Returns
Type | Description |
---|---|
byte[] | The byte array. |
ReadToEndAsync(Stream)
Asynchronously reads all bytes from the current position to the end of the stream.
Declaration
public static Task<byte[]> ReadToEndAsync(this Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The source stream. |
Returns
Type | Description |
---|---|
Task<byte[]> | The byte array. |
Write(Stream, byte[])
Writes a byte array to a stream.
Declaration
public static void Write(this Stream stream, byte[] bytes)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream. |
byte[] | bytes | The byte array. |
WriteAsync(Stream, byte[])
Asynchronously writes a byte array to a stream.
Declaration
public static Task WriteAsync(this Stream stream, byte[] bytes)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream. |
byte[] | bytes | The byte array. |
Returns
Type | Description |
---|---|
Task | The tracking Task. |