Compressing XML data using Lniq and GZipStream

This is a discussion on Compressing XML data using Lniq and GZipStream within the C# Programming forums, part of the General Programming Boards category; Hello, I am attempting to write a small utility for switching WoW user interfaces, and because the grand majority of ...

Compressing XML data using Lniq and GZipStream

Hello, I am attempting to write a small utility for switching WoW user interfaces, and because the grand majority of the data is text, I decided to store all of it in XML files. I wrote these small functions. (note this are not the final code that will go into my program, it contains some quick fixes that should do the same thing, IE the 'kindalocal' variable)

When written directly as an XML file (using XDocument.Save(string)), I can open it in IE and view everything. But this resulted in very large files (about 40MB for 5MB of data), so I decided to compress it using the following functions.

From what I gather, from the example code, is you have any stream that gets a GZipStream wrapped around it. When you call GZipStream.Read(byte[],int,int), it puts the decompressed data from the encapsulated stream into the first parameter. *Thoroughly confused*

Last edited by Aeixious; 01-16-2009 at 02:47 PM.
Reason: More information

I wrote the following as a test. Simply take a file, read it, compress it, decompress it, then compare the data. Fails on EVERY file. The lengths are off, usually by one or two, and even if they were on, the data is different toward the end.

I'm usually not one to assume there is a bug... but this is about as simple as I can get it before manually compressing my computer into a wall. The sad thing is the sample code in MSDN works perfectly. I'm so very confused.

Edit: Never mind I posted here. A gz.Close() was all I needed. Please Never speak of this again.