System.IO.Stream.ReadStream()

Here are the examples of the csharp api System.IO.Stream.ReadStream() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

19 Source : Extensions.cs
with GNU Affero General Public License v3.0
from MaxtorCoder

public static string ReadBinary(this Stream source)
        {
            if (source == null)
                return "NULL";

            try
            {
                var message = source.ReadStream();
                var buffer = new byte[message.Length];

                message.Read(buffer, 0, buffer.Length);
                message.Dispose();

                return BitConverter.ToString(buffer).Replace("-", " ");
            }
            catch
            {
                return "NULL";
            }
        }

19 Source : Extensions.cs
with GNU Affero General Public License v3.0
from MaxtorCoder

public static string ReadText(this Stream source)
        {
            if (source == null)
                return "NULL";

            try
            {
                var message = source.ReadStream();
                var buffer = new byte[message.Length];

                message.Read(buffer, 0, buffer.Length);
                message.Dispose();

                return Encoding.UTF8.GetString(buffer);
            }
            catch
            {
                return "NULL";
            }
        }