c# byte转stream 和 stream 转 bye
Stream 和 byte[] 之间的转换
/* - - - - - - - - - - - - - - - - - - - - - - - -
* Stream 和 byte[] 之间的转换
* - - - - - - - - - - - - - - - - - - - - - - - */
/// <summary>
/// 将 Stream 转成 byte[]
/// </summary>
public byte[] StreamToBytes(Stream stream)
{
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);// 设置当前流的位置为流的开始
stream.Seek(0, SeekOrigin.Begin);
return bytes;
}
/// <summary>
/// 将 byte[] 转成 Stream
/// </summary>
public Stream BytesToStream(byte[] bytes)
{
Stream stream = new MemoryStream(bytes);
return stream;
}
相关文章
文章评论
热门评论
暂无评论


SVN提交时报:both sides of the move must be committed together.出现这个提示的时候,无论你怎么操作,就是提...
很遗憾,会生活家庭记账本软件是单机软件,你所有的数据都存在你的电脑上。设计之初是为了数据的安全性,所以...
有道的购物助手真是恶心啊,卸也没法卸载掉.十足的流氓软件!!!
现在博客取消了CDN加速,直接解析到的服务器,果然收录量提升了一些,收录量从前天的47到今天的60个了.以前就听...
