如何把byte[]读到Stream对象中

coolszy 2010-11-11 12:56:29
如何把byte[]读到Stream对象中
...全文
144 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
兔子-顾问 2010-11-11
  • 打赏
  • 举报
回复
Stream的Write方法可以写入byte数组
snowmagic 2010-11-11
  • 打赏
  • 举报
回复
MemorySteam ms = new MemoryStream(bytes);
CGabriel 2010-11-11
  • 打赏
  • 举报
回复
byte[] buff;
Stream s = new MemoryStream(buff);
兔子-顾问 2010-11-11
  • 打赏
  • 举报
回复
stream是对基于流驱动设备的抽象。比如文件、网络、并口、串口都是基于流驱动的。对应的子类才可以创建,例如
MemoryStream ms = new MemoryStream();//字节流隐射为流操作的方法

FileStream fs = System.IO.File.Open("文件");//文件打开

SerialPort comm = new SerialPort();
Stream s = comm.InnerStream;//串口流驱动方式通讯
coolszy 2010-11-11
  • 打赏
  • 举报
回复
问题是Stream对象怎么创建???
mayubao601 2010-11-11
  • 打赏
  • 举报
回复
stream.Read(b, 0, b.Length);

stream是你的 Stream
b 是你的 byte[]

110,568

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧