public static class StreamConverter
{
#region Public methods
public static byte[] ToBytes(Stream stream)
{
long initialPosition = stream.Position;
stream.Position = 0;
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
stream.Position = initialPosition;
return bytes;
}
public static Stream ToStream(byte[] bytes)
{
return new MemoryStream(bytes);
}
#endregion Public methods
}
Dream Theater: Train of Thought
|