本文整理汇总了C#中System.Xml.XmlTextWriter.WriteBase64方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlTextWriter.WriteBase64方法的具体用法?C# System.Xml.XmlTextWriter.WriteBase64怎么用?C# System.Xml.XmlTextWriter.WriteBase64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlTextWriter
的用法示例。
在下文中一共展示了System.Xml.XmlTextWriter.WriteBase64方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveToFile
protected virtual void SaveToFile(DataSet pDataSet)
{
if (m_FileName == null)
throw new ApplicationException("FileName is null");
byte[] completeByteArray;
using (System.IO.MemoryStream fileMemStream = new System.IO.MemoryStream())
{
System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter(fileMemStream, System.Text.Encoding.UTF8);
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("filedataset", c_DataNamespace);
xmlWriter.WriteStartElement("header", c_DataNamespace);
//File Version
xmlWriter.WriteAttributeString(c_FileVersion, c_FileVersionNumber.ToString());
//Data Version
xmlWriter.WriteAttributeString(c_DataVersion, GetDataVersion().ToString());
//Data Format
xmlWriter.WriteAttributeString(c_DataFormat, ((int)mSaveDataFormat).ToString());
xmlWriter.WriteEndElement();
xmlWriter.WriteStartElement("data", c_DataNamespace);
byte[] xmlByteArray;
using (System.IO.MemoryStream xmlMemStream = new System.IO.MemoryStream())
{
StreamDataSet.Write(xmlMemStream, pDataSet, mSaveDataFormat);
//pDataSet.WriteXml(xmlMemStream);
xmlByteArray = xmlMemStream.ToArray();
xmlMemStream.Close();
}
xmlWriter.WriteBase64(xmlByteArray, 0, xmlByteArray.Length);
xmlWriter.WriteEndElement();
xmlWriter.WriteEndElement();
xmlWriter.WriteEndDocument();
xmlWriter.Flush();
completeByteArray = fileMemStream.ToArray();
fileMemStream.Close();
}
//se tutto è andato a buon fine scrivo effettivamente il file
using (System.IO.FileStream fileStream = new System.IO.FileStream(m_FileName, System.IO.FileMode.Create, System.IO.FileAccess.Write))
{
fileStream.Write(completeByteArray, 0, completeByteArray.Length);
fileStream.Close();
}
}