XmlReader.ReadContentAsBase64(Byte[], Int32, Int32) 方法

定义

读取内容并返回 Base64 解码的二进制字节。Reads the content and returns the Base64 decoded binary bytes.

public:
 virtual int ReadContentAsBase64(cli::array <System::Byte> ^ buffer, int index, int count);
public virtual int ReadContentAsBase64 (byte[] buffer, int index, int count);
abstract member ReadContentAsBase64 : byte[] * int * int -> int
override this.ReadContentAsBase64 : byte[] * int * int -> int
Public Overridable Function ReadContentAsBase64 (buffer As Byte(), index As Integer, count As Integer) As Integer

参数

buffer
Byte[]

结果文本复制到的缓冲区。The buffer into which to copy the resulting text. 此值不能为 nullThis value cannot be null.

index
Int32

缓冲区中的偏移,从这个位置开始将结果复制到缓冲区中。The offset into the buffer where to start copying the result.

count
Int32

要复制到缓冲区的最大字节数。The maximum number of bytes to copy into the buffer. 此方法返回复制的实际字节数。The actual number of bytes copied is returned from this method.

返回

Int32

写入缓冲区的字节数。The number of bytes written to the buffer.

例外

buffer 值为 nullThe buffer value is null.

当前节点不支持 ReadContentAsBase64(Byte[], Int32, Int32)ReadContentAsBase64(Byte[], Int32, Int32) is not supported on the current node.

- 或 --or-

在上一次异步操作完成之前调用了 XmlReader 方法。An XmlReader method was called before a previous asynchronous operation finished. 在此情况下,会引发 InvalidOperationException 并显示消息“异步操作已在进行中。”In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."

缓冲区中的索引或者索引与计数之和大于分配的缓冲区大小。The index into the buffer or index + count is larger than the allocated buffer size.

XmlReader 实现不支持此方法。The XmlReader implementation does not support this method.

注解

此方法对内容进行流式处理、对 Base64 内容进行解码并返回解码的二进制字节 (例如,将内联 Base64 编码的 GIF 图像) 到缓冲区中。This method streams the content, decodes the Base64 content, and returns the decoded binary bytes (for example, an inline Base64 encoded GIF image) into the buffer. 可以连续调用此方法以读取大量嵌入文本。This method can be called successively to read large streams of embedded text. 有关详细信息,请参阅 RFC 1521 "MIME (多用途 Internet 邮件扩展) 第一项:用于指定和描述 Internet 邮件正文格式的机制"。For more information, see RFC 1521, "MIME (Multipurpose Internet Mail Extensions) Part One: Mechanisms for Specifying and Describing the Format of Internet Message Bodies". 你可以从 征求意见网站获取 rfc。You can obtain RFCs from the Request for Comments Web site.

备注

在方法返回值之前,不应访问方法之间的任何读取器属性 ReadContentAsBase64 0You should not access any of the reader properties between calls to the ReadContentAsBase64 method until the method returns the value 0.

此方法具有以下行为:This method has the following behavior:

  • ReadContentAsBase640当达到其所操作的字节流的末尾时,返回该值。ReadContentAsBase64 returns the value 0 when it has reached the end of the byte stream it was operating on. 读取器定位在第一个非内容节点上。The reader is positioned on the first non-content node.

  • 如果要求的数量少于或等于的字节数,则读取器将保留在其当前位置。If you ask for fewer, or the exact number of, bytes than are left in the stream the reader remains in its current position.

  • ReadContentAsBase64 以下 XML 节点类型不支持: Element 、、 XmlDeclaration NoneDocument 、、 DocumentType Notation Entity 、和 DocumentFragmentReadContentAsBase64 is not supported on the following XML node types: Element, XmlDeclaration, None, Document, DocumentType, Notation, Entity, DocumentFragment.

有关此方法的异步版本,请参阅 ReadContentAsBase64AsyncFor the asynchronous version of this method, see ReadContentAsBase64Async.

适用于

另请参阅