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

定义

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

public:
 override int ReadContentAsBase64(cli::array <System::Byte> ^ buffer, int index, int count);
public override int ReadContentAsBase64 (byte[] buffer, int index, int count);
override this.ReadContentAsBase64 : byte[] * int * int -> int
Public Overrides 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.

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

注解

备注

在 .NET Framework 2.0 中,建议的做法是 XmlReader 使用 XmlReaderSettings 类和方法创建实例 CreateIn the .NET Framework 2.0, the recommended practice is to create XmlReader instances using the XmlReaderSettings class and the Create method. 这允许您充分利用 .NET Framework 中引入的所有新功能。This allows you to take full advantage of all the new features introduced in the .NET Framework. 有关详细信息,请参阅 "参考" 页中的 "备注" 部分 XmlReaderFor more information, see the Remarks section in the XmlReader reference page.

此方法对内容进行流式处理,对 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 返回值0之前,不应访问方法之间的任何读取器属性。You 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:

  • ReadContentAsBase64 当值达到其所操作的字节流的末尾时,返回值0。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、None、Document、DocumentType、Notation、Entity、DocumentFragment。ReadContentAsBase64 is not supported on the following XML node types: Element, XmlDeclaration, None, Document, DocumentType, Notation, Entity, DocumentFragment.

适用于

另请参阅