Exemplo n.º 1
0
        public static void WriteXmlAndGzip(StudyXmlMemento theMemento, Stream theXmlStream, Stream theGzipStream)
        {
            // Write to a memory stream, then flush to disk and to gzip file
            var ms = new LargeMemoryStream();

            Write(theMemento, ms);

            var compressedzipStream = new GZipStream(theGzipStream, CompressionMode.Compress, true);

            ms.Seek(0, SeekOrigin.Begin);
            ms.WriteTo(compressedzipStream);

            // Close the stream.
            compressedzipStream.Flush();
            compressedzipStream.Close();

            ms.Seek(0, SeekOrigin.Begin);
            ms.WriteTo(theXmlStream);

            // Force a flush.
            theXmlStream.Flush();
            theGzipStream.Flush();
        }