本文整理汇总了C#中System.Xml.XmlTextReader.ReadBase64方法的典型用法代码示例。如果您正苦于以下问题:C# XmlTextReader.ReadBase64方法的具体用法?C# XmlTextReader.ReadBase64怎么用?C# XmlTextReader.ReadBase64使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.ReadBase64方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.IO;
using System.Xml;
public class Sample {
private const string filename = "binary.xml";
public static void Main() {
XmlTextReader reader = null;
try {
reader = new XmlTextReader(filename);
reader.WhitespaceHandling = WhitespaceHandling.None;
// Read the file. Stop at the Base64 element.
while (reader.Read()) {
if ("Base64" == reader.Name) break;
}
// Read the Base64 data. Write the decoded
// bytes to the console.
Console.WriteLine("Reading Base64... ");
int base64len = 0;
byte[] base64 = new byte[1000];
do {
base64len = reader.ReadBase64(base64, 0, 50);
for (int i=0; i < base64len; i++) Console.Write(base64[i]);
} while (reader.Name == "Base64");
// Read the BinHex data. Write the decoded
// bytes to the console.
Console.WriteLine("\r\nReading BinHex...");
int binhexlen = 0;
byte[] binhex = new byte[1000];
do {
binhexlen = reader.ReadBinHex(binhex, 0, 50);
for (int i=0; i < binhexlen; i++) Console.Write(binhex[i]);
} while (reader.Name == "BinHex");
}
finally {
Console.WriteLine();
Console.WriteLine("Processing of the file {0} complete.", filename);
if (reader != null)
reader.Close();
}
}
}