C# Class NanoByte.Common.Streams.StreamUtils

Provides Stream-related helper methods.
Mostra file Open project: nano-byte/common

Public Methods

Method Description
ContentEquals ( [ stream1, [ stream2 ) : bool

Compares two streams for bit-wise equality. Seeks to the beginnings of the streams if Stream.CanSeek.

Will try to Stream.Seek to the start of both streams.

CopyEmbeddedToFile ( [ type, [ name, [ path ) : void

Copies an embedded resource to a file.

CopyToFile ( [ stream, [ path, int bufferSize = 4096, CancellationToken cancellationToken = default(CancellationToken), Tasks progress = null ) : void

Writes the entire content of a stream to a file.

Write ( [ stream, [ data ) : void

Writes the entire contents of an array to a stream.

Private Methods

Method Description
CopyToEx ( [ source, [ destination, int bufferSize = 4096, CancellationToken cancellationToken = default(CancellationToken), Tasks progress = null ) : void
GetEmbeddedBytes ( [ type, [ name ) : byte[]
GetEmbeddedStream ( [ type, [ name ) : Stream
GetEmbeddedString ( [ type, [ name, [ encoding = null ) : string
Read ( [ stream, int count, bool throwOnEnd = true ) : byte[]
ReadToString ( [ stream, [ encoding = null ) : string
ToArray ( [ stream ) : byte[]
ToStream ( [ data, [ encoding = null ) : MemoryStream

Method Details

ContentEquals() public static method

Compares two streams for bit-wise equality. Seeks to the beginnings of the streams if Stream.CanSeek.
Will try to Stream.Seek to the start of both streams.
public static ContentEquals ( [ stream1, [ stream2 ) : bool
stream1 [
stream2 [
return bool

CopyEmbeddedToFile() public static method

Copies an embedded resource to a file.
The specified embedded resource does not exist.
public static CopyEmbeddedToFile ( [ type, [ name, [ path ) : void
type [ A type that is located in the same namespace as the embedded resource.
name [ The name of the embedded resource.
path [ The path of the file to write.
return void

CopyToFile() public static method

Writes the entire content of a stream to a file.
public static CopyToFile ( [ stream, [ path, int bufferSize = 4096, CancellationToken cancellationToken = default(CancellationToken), Tasks progress = null ) : void
stream [ The stream to read from.
path [ The path of the file to write.
bufferSize int The size of the buffer to use for copying in bytes.
cancellationToken NanoByte.Common.Tasks.CancellationToken Used to signal when the user wishes to cancel the copy process.
progress Tasks Used to report back the number of bytes that have been copied so far. Callbacks are rate limited to once every 250ms.
return void

Write() public static method

Writes the entire contents of an array to a stream.
public static Write ( [ stream, [ data ) : void
stream [ The stream to write to.
data [ The array containing the bytes to write.
return void