System.Xml.XmlWriter.WriteChars C# (CSharp) Method

WriteChars() public abstract method

public abstract WriteChars ( char buffer, int index, int count ) : void
buffer char
index int
count int
return void
        public abstract void WriteChars(char[] buffer, int index, int count);

Usage Example

Example #1
0
    void IXmlSerializable.WriteXml(System.Xml.XmlWriter writer)
    {
        // This is the chunking code.
        // ASP.NET buffering must be turned off for this to work.


        int bufferSize = 4096;

        char[]     songBytes = new char[bufferSize];
        FileStream inFile    = File.Open(this.filePath, FileMode.Open, FileAccess.Read);

        long length = inFile.Length;

        // Write the file name.
        writer.WriteElementString("fileName", ns, Path.GetFileNameWithoutExtension(this.filePath));

        // Write the size.
        writer.WriteElementString("size", ns, length.ToString());

        // Write the song bytes.
        writer.WriteStartElement("song", ns);

        StreamReader sr      = new StreamReader(inFile, true);
        int          readLen = sr.Read(songBytes, 0, bufferSize);

        while (readLen > 0)
        {
            writer.WriteStartElement("chunk", ns);
            writer.WriteChars(songBytes, 0, readLen);
            writer.WriteEndElement();

            writer.Flush();
            readLen = sr.Read(songBytes, 0, bufferSize);
        }

        writer.WriteEndElement();
        inFile.Close();
    }
All Usage Examples Of System.Xml.XmlWriter::WriteChars