/// 将 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;

}

/// 将 byte[] 转成 Stream

public Stream BytesToStream(byte[] bytes)

{

Stream stream = new MemoryStream(bytes);

return stream;

}

posted on 2017-08-08 13:22  田坤坤  阅读(213)  评论(0编辑  收藏  举报