对Stream流的疑惑

yxc504 2010-01-08 09:56:49
在C#里,有各种各样的流Stream
FileStream/MemoryStream....

我想知道需要读取文件的时候,为什么要使用流?
直接读取不也行么?
像C语言中读取文件就不需要使用流?。
...全文
120 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
麦田追风 2010-01-09
  • 打赏
  • 举报
回复
C语言里用open ,.NET里new一个stream 一样的道理啊
Dobzhansky 2010-01-09
  • 打赏
  • 举报
回复
In the beginning, open,read,write,lseek and close was born.
xr396464010 2010-01-09
  • 打赏
  • 举报
回复
up
Dobzhansky 2010-01-09
  • 打赏
  • 举报
回复
everything is file - UNIX
everything is Stream - .net
cranium 2010-01-09
  • 打赏
  • 举报
回复
[Quote=Streams in .NET]
A stream is an abstract representation of a serial device for storing and retrieving data one byte at a time- the underlying device can be a file, a printer, or a network socket for example. Through this abstraction, different devices can be accessed with the same process, and similar code can be used to read data from a file input stream as can be used to read data from a network input stream for example.
[/Quote]
先清楚什么是流,就知道为什么用它。
mngzilin 2010-01-08
  • 打赏
  • 举报
回复
看楼上云气云舒,学习
  • 打赏
  • 举报
回复
例如 System.IO.File.ReadText之类的 --> 例如 System.IO.File.ReadAllText之类的


还有诸如 ReadAllLines、ReadAllBytes,等等。
  • 打赏
  • 举报
回复
在.net中,有很多对文件的直接操作,例如 System.IO.File.ReadText之类的,很多,你仔细看看,.net有没有“直接读取”的?
  • 打赏
  • 举报
回复
fread也是通过read来完成的,只不过是把利用缓冲很小且固定的read流来实现一个傻瓜化的包装。
vrhero 2010-01-08
  • 打赏
  • 举报
回复
你用C语言读写个几G的大文件试试,网络传输就先不说了...

111,125

社区成员

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

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

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