使用 Stream.BeginRead 方法时如何判断数据的来源?

发布于 2024-09-05 05:09:59 字数 602 浏览 5 评论 0原文

当使用 Stream.BeginRead 方法,并且您正在从流中读取数据到内存中时,如何确定您从哪里读取数据?

看: http://msdn.microsoft.com/en- us/library/system.io.stream.beginread.aspx

在参数列表中,我没有看到一个告诉从哪里读取数据的参数:

参数

  • buffer 类型:System.Byte[] The buffer to将数据读入。
  • offset 类型:System.Int32 缓冲区中开始写入从流中读取的数据的字节偏移量
  • count 类型:System.Int32 要读取的最大字节数。
  • callback 类型:System.AsyncCallback 一个可选的异步回调,在读取完成时调用。
  • state 类型:System.Object 用户提供的对象,用于区分此特定异步读取请求和其他异步读取请求 请求。

When using the Stream.BeginRead Method, and you are reading from a stream into a memory, how is it determined where you are reading the data from?

See:
http://msdn.microsoft.com/en-us/library/system.io.stream.beginread.aspx

In the list of parameters, I do not see one that tells where the data is being read from:

Parameters

  • buffer Type: System.Byte[] The buffer to read the data into.
  • offset Type: System.Int32 The byte offset in buffer at which to begin writing data read from the stream
  • count Type: System.Int32 The maximum number of bytes to read.
  • callback Type: System.AsyncCallback An optional asynchronous callback, to be called when the read is complete.
  • state Type: System.Object A user-provided object that distinguishes this particular asynchronous read request from other
    requests.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟─花易冷 2024-09-12 05:09:59

它从流到达的任何位置读取数据,由 位置属性

请注意,并非所有流都支持查找,因此您不一定要设置 Position

It reads the data from wherever the stream is up to, as determined by the Position property.

Note that not all streams support seeking, so you cannot necessarily set Position.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文