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;
}
相关文章
文章评论
热门评论
暂无评论


更新新版本酷狗后,发现后我经常听的歌曲全变成了VIP才能听的歌曲..我以为就我一个人出现的这样,结果查了一下...
百度二类电商度小店提交商品审核后被拒绝的原因:您提交的内容可能涉及URL主域一致性策略,不符合相关规定,请...
使用PUTTY远程链接linux服务器时提示:the servers host key is not cached in the registry. you have no g...
玩过拼多多的都知道,拼多多每笔成交都是要付技术服务费的。拼多多技术服务费是多少钱?答案是拼多多技术服务...
