GZipStream and XmlTextWriter
Hi All,
I have been looking at the best way of doing this but can't find a solution that doesn't involve using bytes array.
Basically I want to wrap a XmlTextWriter in a GZipStream so I produce a GZipped Xml file.
I have been trying this:
using (GZipStream gzipout = new GZipStream(File.Create(Path), CompressionMode.Compress))
{
XmlTextWriter xtw = new XmlTextWriter(gzipout, Encoding.UTF8);
... [write elements and attributes, etc]
}
But I end up with a gzipped file of 4096 bytes and when I look into it my XML content is truncated. The thing is that my content length is really variable.
Please give your thoughts,
Thanks,