Stream Byte[] 转换

public byte[] StreamToBytes(Stream stream)
{
    byte[] bytes = new byte[stream.Length];
    stream.Read(bytes, 0, bytes.Length);
    stream.Seek(0, SeekOrigin.Begin);
    return bytes;
}
  
public Stream BytesToStream(byte[] bytes)
{
    Stream stream = new MemoryStream(bytes);
    return stream;
}
posted @ 2016-05-09 10:55  zslm___  阅读(150)  评论(0编辑  收藏  举报