public bool Save(string sFileName) { using (FileStream fs = File.OpenWrite(sFileName)) { Byte[] xml = new UTF8Encoding(true).GetBytes(this.XML); fs.SetLength(xml.GetLength(0)); fs.Write(xml, 0, xml.Length); } return(true); }
private static XmlDictionaryReader CreateReaderWithQuotas(string root) { byte[] bytes = new UTF8Encoding().GetBytes(root); return(XmlDictionaryReader.CreateTextReader(bytes, 0, bytes.GetLength(0), null, DefaultQuotas, null)); }
public void WriteXml(XmlWriter xmlWriter) { StringWriter w = new StringWriter(CultureInfo.InvariantCulture); XmlTextWriter writer = new XmlTextWriter(w); this.schema.Write(writer); writer.Flush(); byte[] bytes = new UTF8Encoding().GetBytes(w.ToString()); XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas { MaxDepth = 0x20, MaxStringContentLength = 0x2000, MaxArrayLength = 0x4000, MaxBytesPerRead = 0x1000, MaxNameTableCharCount = 0x4000 }; XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(bytes, 0, bytes.GetLength(0), null, quotas, null); if ((reader.MoveToContent() == XmlNodeType.Element) && (reader.Name == "xs:schema")) { xmlWriter.WriteNode(reader, false); } reader.Close(); }